ZQuest Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2024-10-16 04:38:54
Exec Total Coverage
Lines: 9106 12042 75.6%
Functions: 354 407 87.0%
Branches: 7249 12802 56.6%

Line Branch Exec Source
1 #include <cstring>
2 #include <stdio.h>
3 #include "base/zc_alleg.h"
4 #include "zc/guys.h"
5 #include "zc/replay.h"
6 #include "zc/zc_ffc.h"
7 #include "zc/zelda.h"
8 #include "base/zsys.h"
9 #include "base/msgstr.h"
10 #include "zc/maps.h"
11 #include "zc/hero.h"
12 #include "subscr.h"
13 #include "zc/ffscript.h"
14 #include "gamedata.h"
15 #include "defdata.h"
16 #include "zscriptversion.h"
17 #include "particles.h"
18 #include "base/zc_math.h"
19 #include "slopes.h"
20 #include "base/qrs.h"
21 #include "base/dmap.h"
22 #include "base/mapscr.h"
23 #include "base/misctypes.h"
24 #include "base/initdata.h"
25 #include "zc/combos.h"
26 extern particle_list particles;
27
28 extern ZModule zcm;
29 extern HeroClass Hero;
30 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
31
32 int32_t repaircharge=0;
33 bool adjustmagic=false;
34 bool learnslash=false;
35 int32_t wallm_load_clk=0;
36 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
37 int32_t vhead=0;
38 int32_t guycarryingitem=0;
39
40 char *guy_string[eMAXGUYS];
41
42 void never_return(int32_t index);
43 void playLevelMusic();
44
45 // If an enemy is this far out of the playing field, just remove it.
46 #define OUTOFBOUNDS ((int32_t)y>((isSideViewGravity() && canfall(id))?192:352) || y<-176 || x<-256 || x > 512)
47 //#define NEWOUTOFBOUNDS ((int32_t)y>32767 || y<-32767 || x<-32767 || x > 32767)
48 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
49 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
50
51 1111857 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
52 {
53 1111857 int32_t c = coord.getInt();
54
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 1111590 times.
1111857 if(nearest_half)
55 {
56
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1111590 times.
1111590 if (c < 0)
57 c -= val / 2;
58 1111590 else c += (val/2);
59 1111590 }
60 1111857 c -= c % val;
61 1111857 coord = c;
62 1111857 }
63
64 bool NEWOUTOFBOUNDS(zfix x, zfix y, zfix z)
65 {
66 return
67 (
68 (((int32_t)y) > FFCore.enemy_removal_point[spriteremovalY2])
69 || (((int32_t)y) < FFCore.enemy_removal_point[spriteremovalY1])
70 || (((int32_t)x) < FFCore.enemy_removal_point[spriteremovalX1])
71 || (((int32_t)x) > FFCore.enemy_removal_point[spriteremovalX2])
72 || (((int32_t)z) < FFCore.enemy_removal_point[spriteremovalZ1])
73 || (((int32_t)z) > FFCore.enemy_removal_point[spriteremovalZ2])
74 );
75 }
76
77 namespace
78 {
79 int32_t trapConstantHorizontalID;
80 int32_t trapConstantVerticalID;
81 int32_t trapLOSHorizontalID;
82 int32_t trapLOSVerticalID;
83 int32_t trapLOS4WayID;
84
85 int32_t cornerTrapID;
86 int32_t centerTrapID;
87
88 int32_t rockID;
89 int32_t zoraID;
90 int32_t statueID;
91 }
92
93 367 void identifyCFEnemies()
94 {
95 367 trapConstantHorizontalID=-1;
96 367 trapConstantVerticalID=-1;
97 367 trapLOSHorizontalID=-1;
98 367 trapLOSVerticalID=-1;
99 367 trapLOS4WayID=-1;
100 367 cornerTrapID=-1;
101 367 centerTrapID=-1;
102 367 rockID=-1;
103 367 zoraID=-1;
104 367 statueID=-1;
105
106
2/2
✓ Branch 0 taken 187904 times.
✓ Branch 1 taken 367 times.
188271 for(int32_t i=0; i<eMAXGUYS; i++)
107 {
108
3/4
✓ Branch 0 taken 362 times.
✓ Branch 1 taken 187542 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 362 times.
187904 if((guysbuf[i].flags&guy_trph) && trapLOSHorizontalID==-1)
109 362 trapLOSHorizontalID=i;
110
4/4
✓ Branch 0 taken 373 times.
✓ Branch 1 taken 187531 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 367 times.
187904 if((guysbuf[i].flags&guy_trpv) && trapLOSVerticalID==-1)
111 367 trapLOSVerticalID=i;
112
3/4
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 187537 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 367 times.
187904 if((guysbuf[i].flags&guy_trp4) && trapLOS4WayID==-1)
113 367 trapLOS4WayID=i;
114
3/4
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 187537 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 367 times.
187904 if((guysbuf[i].flags&guy_trplr) && trapConstantHorizontalID==-1)
115 367 trapConstantHorizontalID=i;
116
3/4
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 187537 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 367 times.
187904 if((guysbuf[i].flags&guy_trpud) && trapConstantVerticalID==-1)
117 367 trapConstantVerticalID=i;
118
119
3/4
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 187537 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 367 times.
187904 if((guysbuf[i].flags&guy_trap) && cornerTrapID==-1)
120 367 cornerTrapID=i;
121
3/4
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 187537 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 367 times.
187904 if((guysbuf[i].flags&guy_trp2) && centerTrapID==-1)
122 367 centerTrapID=i;
123
124
3/4
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 187537 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 367 times.
187904 if((guysbuf[i].flags&guy_rock) && rockID==-1)
125 367 rockID=i;
126
4/4
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 187518 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 365 times.
187904 if((guysbuf[i].flags&guy_zora) && zoraID==-1)
127 365 zoraID=i;
128
129
4/4
✓ Branch 0 taken 426 times.
✓ Branch 1 taken 187478 times.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 367 times.
187904 if((guysbuf[i].flags & guy_fire) && statueID==-1)
130 367 statueID=i;
131 187904 }
132 367 }
133
134 32 int32_t random_layer_enemy()
135 {
136 32 int32_t cnt=count_layer_enemies();
137
138
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(cnt==0)
139 {
140 return eNONE;
141 }
142
143 32 int32_t ret=zc_oldrand()%cnt;
144 32 cnt=0;
145
146
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 for(int32_t i=0; i<6; ++i)
147 {
148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(tmpscr->layermap[i]!=0)
149 {
150 32 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
151
152
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 for(int32_t j=0; j<10; ++j)
153 {
154
2/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140 times.
140 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
155 {
156
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 108 times.
140 if(cnt==ret)
157 {
158 32 return layerscreen->enemy[j];
159 }
160
161 108 ++cnt;
162 108 }
163 108 }
164 }
165 }
166
167 return eNONE;
168 32 }
169
170 49 int32_t count_layer_enemies()
171 {
172 49 int32_t cnt=0;
173
174
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 49 times.
343 for(int32_t i=0; i<6; ++i)
175 {
176
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 79 times.
294 if(tmpscr->layermap[i]!=0)
177 {
178 79 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
179
180
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 79 times.
869 for(int32_t j=0; j<10; ++j)
181 {
182
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 420 times.
790 if(layerscreen->enemy[j]!=0)
183 {
184 420 ++cnt;
185 420 }
186 790 }
187 79 }
188 294 }
189
190 49 return cnt;
191 }
192
193 211789 int32_t hero_on_wall()
194 {
195 211789 zfix lx = Hero.getX();
196 211789 zfix ly = Hero.getY();
197
198
199
200
4/4
✓ Branch 0 taken 189837 times.
✓ Branch 1 taken 21952 times.
✓ Branch 2 taken 8850 times.
✓ Branch 3 taken 180987 times.
211789 if(lx>=48 && lx<=192)
201 {
202
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 180756 times.
180987 if(ly==32) return up+1;
203
204
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 180473 times.
180756 if(ly==128) return down+1;
205 180473 }
206
207
4/4
✓ Branch 0 taken 194033 times.
✓ Branch 1 taken 17242 times.
✓ Branch 2 taken 21403 times.
✓ Branch 3 taken 172630 times.
211275 if(ly>=48 && ly<=112)
208 {
209
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 172407 times.
172630 if(lx==32) return left+1;
210
211
2/2
✓ Branch 0 taken 172303 times.
✓ Branch 1 taken 104 times.
172407 if(lx==208) return right+1;
212 172303 }
213
214 210948 return 0;
215 211789 }
216
217 765531 bool tooclose(int32_t x,int32_t y,int32_t d)
218 {
219
2/2
✓ Branch 0 taken 567822 times.
✓ Branch 1 taken 197709 times.
765531 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
220 }
221
222 3989892 bool enemy::overpit(enemy *e)
223 {
224 // This function (and shadow_overpit) has been broken since it was written, and only
225 // checked the same diagonal of the hitbox, over and over again. The bug is because both
226 // loops used the same variable name.
227 // Checking literally every pixel seems like overkill, so for now let's continue to
228 // do the single diagonal but just once. That's why the outer loop is commented out.
229
230 // for ( int32_t q = 0; q < hxsz; ++q )
231 {
232
2/2
✓ Branch 0 taken 36952798 times.
✓ Branch 1 taken 3970690 times.
40923488 for ( int32_t q = 0; q < hit_height; ++q )
233 {
234 //check every pixel of the hitbox
235
2/2
✓ Branch 0 taken 19202 times.
✓ Branch 1 taken 36933596 times.
36952798 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
236 {
237 //if the hitbox is over a pit, we can't land
238 19202 return true;
239 }
240 36933596 }
241 }
242 3970690 return false;
243 3989892 }
244
245 12248388 bool enemy::shadow_overpit(enemy *e)
246 {
247 // for ( int32_t q = 0; q < hxsz; ++q )
248 {
249
2/2
✓ Branch 0 taken 176016029 times.
✓ Branch 1 taken 12221927 times.
188237956 for ( int32_t q = 0; q < hit_height; ++q )
250 {
251 //check every pixel of the hitbox
252
2/2
✓ Branch 0 taken 26461 times.
✓ Branch 1 taken 175989568 times.
176016029 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
253 {
254 //if the hitbox is over a pit, we can't land
255 26461 return true;
256 }
257 175989568 }
258 }
259 12221927 return false;
260 12248388 }
261
262 // Returns true iff a combo type or flag precludes enemy movement.
263 7430015 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
264 {
265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7430015 times.
7430015 if(moveflags & move_ignore_blockflags) return false;
266 7430015 int32_t c = COMBOTYPE(dx,dy);
267
4/4
✓ Branch 0 taken 4889751 times.
✓ Branch 1 taken 2540264 times.
✓ Branch 2 taken 1398275 times.
✓ Branch 3 taken 1141989 times.
9970279 bool pit_blocks = (!(moveflags & (move_can_pitwalk|move_only_pitwalk)) && (!(moveflags & move_can_pitfall) || !isKB));
268
3/6
✓ Branch 0 taken 2521940 times.
✓ Branch 1 taken 4908075 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2521940 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7430015 bool water_blocks = (!(moveflags & (move_can_waterwalk|move_only_waterwalk|move_only_shallow_waterwalk)) && (!(moveflags & move_can_waterdrown) || !isKB) && get_qr(qr_DROWN));
269
5/6
✓ Branch 0 taken 2581486 times.
✓ Branch 1 taken 4848529 times.
✓ Branch 2 taken 2579609 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 2579609 times.
✗ Branch 5 not taken.
14860794 return c==cPIT || c==cPITB || c==cPITC ||
270
4/6
✓ Branch 0 taken 2579609 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2579609 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2430861 times.
✓ Branch 5 taken 148748 times.
2579609 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
271 // Block enemies type and block enemies flags
272
2/2
✓ Branch 0 taken 2574333 times.
✓ Branch 1 taken 2425585 times.
148748 combo_class_buf[c].block_enemies&1 ||
273
4/4
✓ Branch 0 taken 2571663 times.
✓ Branch 1 taken 2670 times.
✓ Branch 2 taken 2571416 times.
✓ Branch 3 taken 247 times.
2574333 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
274
4/4
✓ Branch 0 taken 2570598 times.
✓ Branch 1 taken 818 times.
✓ Branch 2 taken 2570532 times.
✓ Branch 3 taken 66 times.
2571416 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
275 // Check for ladder-only combos which aren't dried water
276
4/4
✓ Branch 0 taken 10626 times.
✓ Branch 1 taken 2559906 times.
✓ Branch 2 taken 10331 times.
✓ Branch 3 taken 295 times.
5140769 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
277 // Check for drownable water
278
4/4
✓ Branch 0 taken 571946 times.
✓ Branch 1 taken 1998291 times.
✓ Branch 2 taken 1900 times.
✓ Branch 3 taken 570046 times.
2570237 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true, false, false)));
279 2584127 }
280
281 // Returns true iff enemy is floating and blocked by a combo type or flag.
282 8647446 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
283 {
284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8647446 times.
8647446 if(moveflags & move_ignore_blockflags) return false;
285
4/4
✓ Branch 0 taken 6549648 times.
✓ Branch 1 taken 2097798 times.
✓ Branch 2 taken 1749398 times.
✓ Branch 3 taken 348400 times.
10745244 bool pit_blocks = (!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !isKB));
286
3/4
✓ Branch 0 taken 6564155 times.
✓ Branch 1 taken 2083291 times.
✓ Branch 2 taken 2083291 times.
✗ Branch 3 not taken.
10730737 bool water_blocks = (!(moveflags & move_can_waterwalk) && (!(moveflags & move_can_waterdrown) || !isKB));
287
2/2
✓ Branch 0 taken 1200827 times.
✓ Branch 1 taken 7446619 times.
16094065 return ((special==spw_floater)&&
288
2/2
✓ Branch 0 taken 7436494 times.
✓ Branch 1 taken 10125 times.
7446619 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
289
2/2
✓ Branch 0 taken 7436375 times.
✓ Branch 1 taken 119 times.
7436494 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
290
2/2
✓ Branch 0 taken 7436204 times.
✓ Branch 1 taken 171 times.
7436375 (MAPFLAG(dx,dy)==mfNOENEMY)||
291
2/2
✓ Branch 0 taken 7435949 times.
✓ Branch 1 taken 255 times.
7436204 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
292
4/4
✓ Branch 0 taken 1242529 times.
✓ Branch 1 taken 6193420 times.
✓ Branch 2 taken 4004 times.
✓ Branch 3 taken 1238525 times.
14867894 (water_blocks && iswaterex(MAPCOMBO(dx, dy), currmap, currscr, -1, dx,dy, false, false, true)) ||
293
2/2
✓ Branch 0 taken 6183831 times.
✓ Branch 1 taken 1248114 times.
7431945 (pit_blocks && ispitfall(dx,dy))));
294 8647446 }
295 // Returns true iff a combo type or flag precludes enemy movement.
296 268956 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
297 {
298 268956 int32_t c = COMBOTYPE(dx,dy);
299 268956 bool pit_blocks = !(gd.moveflags & move_can_pitwalk);
300
2/2
✓ Branch 0 taken 33457 times.
✓ Branch 1 taken 235499 times.
268956 bool water_blocks = !(gd.moveflags & move_can_waterwalk) && get_qr(qr_DROWN);
301
5/6
✓ Branch 0 taken 268936 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 268819 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 268819 times.
✗ Branch 5 not taken.
1014715 return c==cPIT || c==cPITB || c==cPITC ||
302
4/6
✓ Branch 0 taken 268819 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268819 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239043 times.
✓ Branch 5 taken 29776 times.
268819 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
303 // Block enemies type and block enemies flags
304
2/2
✓ Branch 0 taken 268246 times.
✓ Branch 1 taken 238470 times.
29776 combo_class_buf[c].block_enemies&1 ||
305
4/4
✓ Branch 0 taken 267920 times.
✓ Branch 1 taken 326 times.
✓ Branch 2 taken 267889 times.
✓ Branch 3 taken 31 times.
268246 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
306
4/4
✓ Branch 0 taken 264389 times.
✓ Branch 1 taken 3500 times.
✓ Branch 2 taken 264114 times.
✓ Branch 3 taken 275 times.
267889 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
307 // Check for ladder-only combos which aren't dried water
308
4/4
✓ Branch 0 taken 1042 times.
✓ Branch 1 taken 263072 times.
✓ Branch 2 taken 1003 times.
✓ Branch 3 taken 39 times.
528189 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
309 // Check for drownable water
310
4/4
✓ Branch 0 taken 42397 times.
✓ Branch 1 taken 221678 times.
✓ Branch 2 taken 24004 times.
✓ Branch 3 taken 18393 times.
264075 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)));
311 }
312
313 // Returns true iff enemy is floating and blocked by a combo type or flag.
314 122271 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
315 {
316
2/2
✓ Branch 0 taken 119948 times.
✓ Branch 1 taken 2323 times.
122271 bool pit_blocks = (!(gd.moveflags & move_can_pitwalk) && !(gd.moveflags & move_can_pitfall));
317 122271 bool water_blocks = !(gd.moveflags & move_can_waterwalk);
318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 122271 times.
244542 return ((special==spw_floater)&&
319
2/2
✓ Branch 0 taken 122174 times.
✓ Branch 1 taken 97 times.
122271 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
320
2/2
✓ Branch 0 taken 122169 times.
✓ Branch 1 taken 5 times.
122174 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
321
2/2
✓ Branch 0 taken 122160 times.
✓ Branch 1 taken 9 times.
122169 (MAPFLAG(dx,dy)==mfNOENEMY)||
322
2/2
✓ Branch 0 taken 122131 times.
✓ Branch 1 taken 29 times.
122160 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
323
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 119810 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
244012 (water_blocks && iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)) ||
324
2/2
✓ Branch 0 taken 119810 times.
✓ Branch 1 taken 2071 times.
121881 (pit_blocks && ispitfall(dx,dy))));
325 }
326
327
5/10
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114515 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114515 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 114515 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 114515 times.
✗ Branch 9 not taken.
229030 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
328 114515 {
329
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 x=X;
330
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 y=Y;
331 114515 id=Id;
332 114515 clk=Clk;
333
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 floor_y=y;
334 114515 ceiling=false;
335 114515 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
336 114515 grumble = movestatus = posframe = timer = ox = oy = 0;
337
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114515 times.
✓ Branch 2 taken 114515 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114515 times.
✗ Branch 5 not taken.
114515 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
338 114515 did_armos=true;
339 114515 script_spawned=false;
340
341 114515 d = guysbuf + (id & 0xFFF);
342 114515 hp = d->hp;
343 114515 starting_hp = hp;
344 // cs = d->cset;
345 //d variables
346
347 114515 flags=d->flags;
348 114515 flags=d->flags;
349 114515 s_tile=d->s_tile; //secondary (additional) tile(s)
350 114515 family=d->family;
351 114515 dcset=d->cset;
352 114515 cs=dcset;
353
2/2
✓ Branch 0 taken 88395 times.
✓ Branch 1 taken 26120 times.
114515 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
354 114515 dp=d->dp;
355 114515 wdp=d->wdp;
356 114515 wpn=d->weapon;
357 114515 wpnsprite = d-> wpnsprite; //2.6 -Z
358 114515 rate=d->rate;
359 114515 hrate=d->hrate;
360
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 dstep=d->step;
361 114515 homing=d->homing;
362 114515 dmisc1=d->attributes[0];
363 114515 dmisc2=d->attributes[1];
364 114515 dmisc3=d->attributes[2];
365 114515 dmisc4=d->attributes[3];
366 114515 dmisc5=d->attributes[4];
367 114515 dmisc6=d->attributes[5];
368 114515 dmisc7=d->attributes[6];
369 114515 dmisc8=d->attributes[7];
370 114515 dmisc9=d->attributes[8];
371 114515 dmisc10=d->attributes[9];
372 114515 dmisc11=d->attributes[10];
373 114515 dmisc12=d->attributes[11];
374 114515 dmisc13=d->attributes[12];
375 114515 dmisc14=d->attributes[13];
376 114515 dmisc15=d->attributes[14];
377 114515 dmisc16=d->attributes[15];
378 114515 dmisc17=d->attributes[16];
379 114515 dmisc18=d->attributes[17];
380 114515 dmisc19=d->attributes[18];
381 114515 dmisc20=d->attributes[19];
382 114515 dmisc21=d->attributes[20];
383 114515 dmisc22=d->attributes[21];
384 114515 dmisc23=d->attributes[22];
385 114515 dmisc24=d->attributes[23];
386 114515 dmisc25=d->attributes[24];
387 114515 dmisc26=d->attributes[25];
388 114515 dmisc27=d->attributes[26];
389 114515 dmisc28=d->attributes[27];
390 114515 dmisc29=d->attributes[28];
391 114515 dmisc30=d->attributes[29];
392 114515 dmisc31=d->attributes[30];
393 114515 dmisc32=d->attributes[31];
394
2/2
✓ Branch 0 taken 4074 times.
✓ Branch 1 taken 110441 times.
114515 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
395 {
396 110441 dmisc31 = dmisc32;
397 110441 dmisc32 = 0;
398 110441 }
399 114515 spr_shadow=d->spr_shadow;
400 114515 spr_death=d->spr_death;
401 114515 spr_spawn=d->spr_spawn;
402
403
2/2
✓ Branch 0 taken 4695115 times.
✓ Branch 1 taken 114515 times.
4809630 for(int32_t i=0; i<edefLAST255; i++)
404 4695115 defense[i]=d->defense[i];
405
406 114515 bgsfx=d->bgsfx;
407 114515 hitsfx=d->hitsfx;
408 114515 deadsfx=d->deadsfx;
409 114515 bosspal=d->bosspal;
410 114515 parent_script_UID = 0;
411
412 114515 frozentile = d->frozentile;
413
414 114515 frozencset = d->frozencset;
415 114515 frozenclock = 0;
416
2/2
✓ Branch 0 taken 1145150 times.
✓ Branch 1 taken 114515 times.
1259665 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
417
418
2/2
✓ Branch 0 taken 1946755 times.
✓ Branch 1 taken 114515 times.
2061270 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
419 //firesfx = 0; //t.b.a -Z
420 114515 isCore = true; //t.b.a
421 114515 parentCore = 0; //t.b.a
422
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
423
424 114515 firesfx = d->firesfx;
425
2/2
✓ Branch 0 taken 3664480 times.
✓ Branch 1 taken 114515 times.
3778995 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
426
2/2
✓ Branch 0 taken 3664480 times.
✓ Branch 1 taken 114515 times.
3778995 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
427
428 114515 script = d->script;
429 114515 weaponscript = d->weaponscript;
430
431
2/2
✓ Branch 0 taken 916120 times.
✓ Branch 1 taken 114515 times.
1030635 for ( int32_t q = 0; q < 8; q++ )
432 {
433 916120 initD[q] = d->initD[q];
434 //Z_scripterrlog("(enemy::enemy(zfix)): Loading weapon InitD[%d] to an enemy with a value of (%d)\n",q,d->weap_initiald[q]);
435 916120 weap_initiald[q] = d->weap_initiald[q];
436 916120 }
437
2/2
✓ Branch 0 taken 229030 times.
✓ Branch 1 taken 114515 times.
343545 for ( int32_t q = 0; q < 2; q++ )
438 {
439 229030 initA[q] = d->initA[q];
440 229030 weap_initiala[q] = d->weap_initiala[q];
441 229030 }
442
443 114515 stickclk = 0;
444 114515 submerged = false;
445 114515 didScriptThisFrame = false;
446 114515 ffcactivated = 0;
447 114515 hitdir = -1;
448 114515 dialogue_str = 0; //set by spawn flags.
449 114515 editorflags = d->editorflags; //set by Enemy Editor
450 //Set the drawing flag for this sprite.
451
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
452
453
454
2/2
✓ Branch 0 taken 8858 times.
✓ Branch 1 taken 105657 times.
114515 if(bosspal>-1)
455 {
456
1/2
✓ Branch 0 taken 8858 times.
✗ Branch 1 not taken.
8858 loadpalset(csBOSS,pSprite(bosspal));
457 8858 }
458
459
2/2
✓ Branch 0 taken 49809 times.
✓ Branch 1 taken 64706 times.
114515 if(bgsfx>-1)
460 {
461
1/2
✓ Branch 0 taken 49809 times.
✗ Branch 1 not taken.
49809 cont_sfx(bgsfx);
462 49809 }
463
464
2/2
✓ Branch 0 taken 88395 times.
✓ Branch 1 taken 26120 times.
114515 if(get_qr(qr_NEWENEMYTILES))
465 {
466 88395 o_tile=d->e_tile;
467 88395 frate = d->e_frate;
468 88395 }
469 else
470 {
471 26120 o_tile=d->tile;
472 26120 frate = d->frate;
473 }
474
475 114515 tile=0; //init to 0 here, but set it later.
476
477 114515 scripttile = -1;
478 114515 scriptflip = -1;
479 114515 do_animation = true;
480 114515 immortal = false;
481 114515 noSlide = false;
482 114515 deathexstate = -1;
483
484 114515 hashero=false;
485
486 // If they forgot the invisibility flag, here's another failsafe:
487
4/4
✓ Branch 0 taken 5791 times.
✓ Branch 1 taken 108724 times.
✓ Branch 2 taken 5697 times.
✓ Branch 3 taken 94 times.
114515 if(o_tile==0 && family!=eeSPINTILE)
488
1/2
✓ Branch 0 taken 5697 times.
✗ Branch 1 not taken.
5697 flags |= guy_invisible;
489
490 // step = d->step/100.0;
491 // To preserve the odd step values for Keese & Gleeok heads. -L
492
5/8
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114515 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12145 times.
✓ Branch 5 taken 102370 times.
✓ Branch 6 taken 12145 times.
✗ Branch 7 not taken.
114515 if(dstep==62.0) dstep+=0.5;
493
5/8
✓ Branch 0 taken 102370 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102370 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 699 times.
✓ Branch 5 taken 101671 times.
✓ Branch 6 taken 699 times.
✗ Branch 7 not taken.
102370 else if(dstep==89) dstep-=1/9;
494
495
5/10
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114515 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114515 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 114515 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 114515 times.
✗ Branch 9 not taken.
114515 step = zslongToFix(dstep*100);
496
497
498 114515 item_set = d->item_set;
499 114515 grumble = d->grumble;
500
501
2/2
✓ Branch 0 taken 89921 times.
✓ Branch 1 taken 24594 times.
114515 if(frate == 0)
502 24594 frate = 256;
503
504 114515 leader = itemguy = dying = scored = false;
505 114515 canfreeze = count_enemy = true;
506
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 mainguy = !(flags & guy_doesnt_count);
507
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 dir = zc_oldrand()&3;
508
509 //2.6 Enemy Editor Hit and TIle Sizes
510
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 114506 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
114515 if ( ((d->SIZEflags&OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
511 // al_trace("Enemy txsz:%i\n", txsz);
512
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 114506 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
114515 if ( ((d->SIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
513
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 114508 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
114515 if ( ((d->SIZEflags&OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
514
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 114508 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
114515 if ( ((d->SIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
515
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114515 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114515 if ( ((d->SIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
516
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 if ( (d->SIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
517
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 if ( (d->SIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
518 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
519
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114515 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114515 if ( (d->SIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114515 times.
114515 if ( (d->SIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
521 {
522 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
523 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
524 }
525
526
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114515 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114515 if ( (d->SIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
527
528 114515 SIZEflags = d->SIZEflags;
529
530
8/10
✓ Branch 0 taken 114266 times.
✓ Branch 1 taken 249 times.
✓ Branch 2 taken 366 times.
✓ Branch 3 taken 114149 times.
✓ Branch 4 taken 366 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 366 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 365 times.
114515 if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU))
531 1 wpn = 0;
532
533 //tile should never be 0 after init --Z (failsafe)
534
4/6
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114515 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107954 times.
✓ Branch 5 taken 6561 times.
114515 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
535
536 //Moveflags; for gravity and pit interaction
537 114515 moveflags = d->moveflags;
538
3/4
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17659 times.
✓ Branch 3 taken 96856 times.
114515 if(!can_pitfall(false))
539 {
540 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
541
2/4
✓ Branch 0 taken 17659 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17659 times.
✗ Branch 3 not taken.
17659 moveflags &= ~move_can_pitfall;
542
2/4
✓ Branch 0 taken 17659 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17659 times.
✗ Branch 3 not taken.
17659 moveflags &= ~move_can_waterdrown;
543 17659 }
544
545 114515 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
546
547
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114515 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114515 if (((d->weapoverrideFLAGS & OVERRIDE_TILE_WIDTH) != 0) && d->weap_tilew > 0) { weap_tilew = d->weap_tilew; if (weap_tilew > 1) extend = 3; }
548
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114515 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114515 if (((d->weapoverrideFLAGS & OVERRIDE_TILE_HEIGHT) != 0) && d->weap_tileh > 0) { weap_tileh = d->weap_tileh; if (weap_tileh > 1) extend = 3; }
549
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114515 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114515 if (((d->weapoverrideFLAGS & OVERRIDE_HIT_WIDTH) != 0) && d->weap_hxsz >= 0) weap_hxsz = d->weap_hxsz;
550
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114515 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114515 if (((d->weapoverrideFLAGS & OVERRIDE_HIT_HEIGHT) != 0) && d->weap_hysz >= 0) weap_hysz = d->weap_hysz;
551
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114515 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114515 if (((d->weapoverrideFLAGS & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->weap_hzsz >= 0) weap_hzsz = d->weap_hzsz;
552
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 if ((d->weapoverrideFLAGS & OVERRIDE_HIT_X_OFFSET) != 0) weap_hxofs = d->weap_hxofs;
553
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 if ((d->weapoverrideFLAGS & OVERRIDE_HIT_Y_OFFSET) != 0) weap_hyofs = d->weap_hyofs;
554
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 if ((d->weapoverrideFLAGS & OVERRIDE_DRAW_X_OFFSET) != 0) weap_xofs = (int32_t)d->weap_xofs;
555
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 if ((d->weapoverrideFLAGS & OVERRIDE_DRAW_Y_OFFSET) != 0)
556 {
557 weap_yofs = (int32_t)d->weap_yofs; //This seems to be setting to +48 or something with any value set?! -Z
558 weap_yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
559 }
560 114515 weapoverrideFLAGS = d->weapoverrideFLAGS;
561 114515 wunblockable = d->wunblockable;
562 114515 wmoveflags = d->wmoveflags;
563
2/4
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114515 times.
✗ Branch 3 not taken.
114515 wstep = zslongToFix(d->wstep*100);
564
2/2
✓ Branch 0 taken 572575 times.
✓ Branch 1 taken 114515 times.
687090 for (int q=0; q < WPNSPR_MAX; ++q)
565 {
566 572575 burnsprs[q] = d->burnsprs[q];
567 572575 light_rads[q] = d->light_rads[q];
568 572575 }
569 114515 specialsfx = d->specialsfx;
570 114515 }
571
572 598 int32_t enemy::getScriptUID() { return script_UID; }
573 void enemy::setScriptUID(int32_t new_id) { script_UID = new_id; }
574 114285 enemy::~enemy()
575 114285 {
576
2/4
✓ Branch 0 taken 114285 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114285 times.
✗ Branch 3 not taken.
114285 FFCore.deallocateAllScriptOwned(ScriptType::NPC, getUID());
577
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 114272 times.
114285 if(hashero)
578 {
579
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 Hero.setEaten(0);
580 13 hashero=false;
581 13 }
582 114285 }
583
584 bool enemy::is_move_paused()
585 {
586 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
587 }
588
589 7024 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
590 {
591 7024 int32_t yg = (special==spw_floater)?8:0;
592 7024 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
593 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
594
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_x == -1000)
595 input_x = dx;
596
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_y == -1000)
597 input_y = dy;
598
599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
14048 if(!(moveflags & move_ignore_screenedge)
600
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7024 times.
✓ Branch 4 taken 6707 times.
✓ Branch 5 taken 317 times.
7024 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
601
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 || ((input_x+hit_width-1) >= (240+nb)) || ((input_y+hit_height-1) >= (160+nb))))
602 return true;
603
604
4/6
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 6934 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
7024 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
605 {
606 if(ispitfall(dx,dy))
607 return true;
608 }
609
610 7024 bool flying = false;
611 7024 bool cansolid = false;
612
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(moveflags & move_ignore_solidity)
613 cansolid = true;
614
2/4
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7024 switch(special)
615 {
616 case spw_clipbottomright:
617 if(dy>=128 || dx>=208) return true;
618 break;
619 case spw_clipright:
620 break; //if(input_x>=208) return true; break;
621
622 case spw_wizzrobe: // fall through
623 case spw_floater: // Special case for fliers and wizzrobes - hack!
624 {
625
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
317 if(isdungeon() && !(moveflags & move_ignore_screenedge))
626 {
627 if(dy < 32-yg || dy >= 144) return true;
628 if(dx < 32 || dx >= 224) return true;
629 }
630
2/4
✓ Branch 0 taken 317 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 317 times.
✗ Branch 3 not taken.
317 if(!(moveflags & move_ignore_blockflags) && flyerblocked(dx, dy, special, kb))
631 return true;
632 317 cansolid = true;
633 317 flying = true;
634 }
635 317 }
636
637 7024 dx &= ~7;
638 7024 dy &= ~7;
639
640
4/6
✓ Branch 0 taken 6707 times.
✓ Branch 1 taken 317 times.
✓ Branch 2 taken 6707 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6707 times.
✗ Branch 5 not taken.
7024 if(!flying && !(moveflags & move_ignore_blockflags) && groundblocked(dx,dy,kb)) return true;
641
642
4/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7024 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7024 times.
7024 if (dx < 0 || dx > 255 || dy < 0 || dy > 175)
643 return !(moveflags & move_ignore_screenedge);
644 //_walkflag code
645 mapscr *s1, *s2;
646 7024 s1=(((*tmpscr).layermap[0]-1)>=0)?tmpscr2:NULL;
647 7024 s2=(((*tmpscr).layermap[1]-1)>=0)?tmpscr2+1:NULL;
648
649 7024 int32_t cpos=(dx>>4)+(dy&0xF0);
650
3/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1038 times.
✓ Branch 3 taken 5986 times.
7024 int32_t ci = tmpscr->data[cpos], ci1 = (s1?s1:tmpscr)->data[cpos], ci2 = (s2?s2:tmpscr)->data[cpos];
651 7024 newcombo const& c = combobuf[ci];
652 7024 newcombo const& c1 = combobuf[ci1];
653 7024 newcombo const& c2 = combobuf[ci2];
654
655 7024 int32_t b=1;
656
2/2
✓ Branch 0 taken 3446 times.
✓ Branch 1 taken 3578 times.
7024 if(dx&8) b<<=2;
657
2/2
✓ Branch 0 taken 3374 times.
✓ Branch 1 taken 3650 times.
7024 if(dy&8) b<<=1;
658
659 #define iwtr(cmb, x, y, shallow) \
660 (shallow \
661 ? iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, true, false) \
662 && !iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false) \
663 : iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false))
664 7024 bool wtr = iwtr(ci, dx, dy, false);
665
2/2
✓ Branch 0 taken 3551 times.
✓ Branch 1 taken 3473 times.
7024 bool shwtr = iwtr(ci, dx, dy, true);
666 7024 bool pit = ispitfall(dx,dy);
667
668
3/4
✓ Branch 0 taken 6934 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
7024 bool canwtr = (moveflags & move_can_waterwalk) || ((moveflags & move_can_waterdrown) && kb);
669
3/4
✓ Branch 0 taken 6934 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 90 times.
7024 bool canpit = (moveflags & move_can_pitwalk) || ((moveflags & move_can_pitfall) && kb);
670 7024 bool needwtr = (moveflags & move_only_waterwalk);
671 7024 bool needshwtr = (moveflags & move_only_shallow_waterwalk);
672 7024 bool needpit = (moveflags & move_only_pitwalk);
673
674
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
7024 if(!cansolid)
675 {
676 6707 int32_t cwalkflag = c.walk & 0xF;
677
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6707 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s1)
679 {
680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c1.type == cBRIDGE)
681 {
682 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
683 {
684 int efflag = (c1.walk & 0xF0)>>4;
685 int newsolid = (c1.walk & 0xF);
686 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
687 }
688 else cwalkflag &= c1.walk;
689 }
690 6707 else cwalkflag |= c1.walk & 0xF;
691 6707 }
692
2/2
✓ Branch 0 taken 5986 times.
✓ Branch 1 taken 721 times.
6707 if (s2)
693 {
694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 721 times.
721 if (c2.type == cBRIDGE)
695 {
696 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
697 {
698 int efflag = (c2.walk & 0xF0)>>4;
699 int newsolid = (c2.walk & 0xF);
700 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
701 }
702 else cwalkflag &= c2.walk;
703 }
704 721 else cwalkflag |= c2.walk & 0xF;
705 721 }
706
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 6468 times.
6707 if(cwalkflag & b)
707 239 return true;
708 6468 }
709
3/6
✓ Branch 0 taken 6785 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6785 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6785 times.
6785 if(needwtr || needshwtr || needpit)
710 {
711 bool ret = true;
712 if (needwtr && wtr) ret = false;
713 else if (needshwtr && shwtr) ret = false;
714 else if (needpit && pit) ret = false;
715 return ret;
716 }
717
3/4
✓ Branch 0 taken 3473 times.
✓ Branch 1 taken 3312 times.
✓ Branch 2 taken 3473 times.
✗ Branch 3 not taken.
6785 else if(wtr && !canwtr)
718 return true;
719
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6785 else if(pit && !canpit)
720 return true;
721
722 6785 return false;
723 7024 }
724
725 1535 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
726 {
727
3/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1111 times.
✓ Branch 2 taken 424 times.
✗ Branch 3 not taken.
1535 if(!(dx || dy)) return true;
728 1535 zfix bx = x+hxofs, by = y+hyofs; //left/top
729 1535 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
730
3/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 1019 times.
✗ Branch 3 not taken.
1535 if(!ign_sv && dy < 0) //check gravity
731 {
732 if((moveflags & move_obeys_grav) && isSideViewGravity())
733 return false;
734 }
735
736
2/4
✓ Branch 0 taken 1535 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1535 times.
1535 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
737
738
3/4
✓ Branch 0 taken 1111 times.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1111 times.
1535 if(dx && !dy)
739 {
740
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 341 times.
1111 if(dx < 0)
741 {
742
2/4
✓ Branch 0 taken 770 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 770 times.
770 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
743 770 int mx = (bx+dx).getFloor();
744
2/2
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 770 times.
3746 for(zfix ty = 0; by+ty < ry; ty += 8)
745 {
746
1/2
✓ Branch 0 taken 2976 times.
✗ Branch 1 not taken.
2976 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
747 return false;
748 2976 }
749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 770 times.
770 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
750 return false;
751
3/4
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 736 times.
✗ Branch 3 not taken.
770 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
752 return false;
753 770 }
754 else
755 {
756 341 int mx = (rx+dx).getCeil();
757 341 int lx = mx-hit_width+1;
758
2/2
✓ Branch 0 taken 2142 times.
✓ Branch 1 taken 340 times.
2482 for(zfix ty = 0; by+ty < ry; ty += 8)
759 {
760
2/2
✓ Branch 0 taken 2141 times.
✓ Branch 1 taken 1 times.
2142 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
761 1 return false;
762 2141 }
763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
764 return false;
765
2/4
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
✗ Branch 3 not taken.
340 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
766 return false;
767 }
768 1110 }
769
2/4
✓ Branch 0 taken 424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
424 else if(dy && !dx)
770 {
771
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 109 times.
424 if(dy < 0)
772 {
773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 special = (special==spw_clipbottomright)?spw_none:special;
774 315 int my = (by+dy).getFloor();
775
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 77 times.
469 for(zfix tx = 0; bx+tx < rx; tx += 8)
776 {
777
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 238 times.
392 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
778 238 return false;
779 154 }
780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(scr_walkflag(rx, my, special, up, bx, my, kb))
781 return false;
782
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
77 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
783 return false;
784 77 }
785 else
786 {
787 109 int my = (ry+dy).getCeil();
788 109 int ly = my-hit_height+1;
789
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 109 times.
327 for(zfix tx = 0; bx+tx < rx; tx += 8)
790 {
791
1/2
✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
218 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
792 return false;
793 218 }
794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
795 return false;
796
3/4
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
109 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
797 return false;
798 }
799 186 }
800 else //! Untested, and currently unused.
801 {
802 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
803 }
804 1296 return true;
805 1535 }
806
807 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
808 {
809 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
810 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
811
812 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
813
814 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
815 return false;
816 for(zfix ty = 0; by+ty < ry; ty += 8)
817 {
818 for(zfix tx = 0; bx+tx < rx; tx += 8)
819 {
820 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
821 return false;
822 }
823 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
824 return false;
825 }
826 for(zfix tx = 0; bx+tx < rx; tx += 8)
827 {
828 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
829 return false;
830 }
831 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
832 return false;
833 return true;
834 }
835
836 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
837 {
838 auto oxsz = hit_width, oysz = hit_height;
839 if(nwid > -1) hit_width = nwid;
840 if(nhei > -1) hit_height = nhei;
841 bool ret = scr_canplace(dx,dy,special,kb);
842 hit_width = oxsz; hit_height = oysz;
843 return ret;
844 }
845
846 1311 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
847 {
848 1311 bool ret = true;
849
3/8
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1019 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1311 if(!ign_sv && dy < 0 && (moveflags & move_obeys_grav) && isSideViewGravity())
850 dy = 0;
851 1311 const int scl = 2;
852
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 1345 times.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 1311 times.
1605 while(abs(dx) > scl || abs(dy) > scl)
853 {
854
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 34 times.
294 if(abs(dx) > abs(dy))
855 {
856 260 int32_t tdx = dx.sign() * scl;
857
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
858 260 dx -= tdx;
859 else
860 {
861 if(earlyret) return false;
862 dx = tdx;
863 ret = false;
864 }
865 260 }
866 else
867 {
868 34 int32_t tdy = dy.sign() * scl;
869
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 7 times.
34 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
870 27 dy -= tdy;
871 else
872 {
873
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(earlyret) return false;
874 7 dy = tdy;
875 7 ret = false;
876 }
877 }
878 }
879
880
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 1111 times.
1311 if(dx)
881 {
882
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 1 times.
1111 if(scr_canmove(dx, 0, special, kb, ign_sv))
883 1110 x += dx;
884 else
885 {
886
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(earlyret) return false;
887 ret = false;
888 int xsign = dx.sign();
889 while(scr_canmove(xsign, 0, special, kb, ign_sv))
890 {
891 x += xsign;
892 dx -= xsign;
893 }
894 if(dx)
895 {
896 dx.doDecBound(0,-9999, 0,9999);
897 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
898 if(scr_canmove(val, 0, special, kb, ign_sv))
899 {
900 retval = val;
901 return BSEARCH_CONTINUE_AWAY0;
902 }
903 else return BSEARCH_CONTINUE_TOWARD0;
904 });
905 x += dx;
906 }
907 }
908 1110 }
909
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 200 times.
1310 if(dy)
910 {
911
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 14 times.
200 if(scr_canmove(0, dy, special, kb, ign_sv))
912 186 y += dy;
913 else
914 {
915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(earlyret) return false;
916 14 ret = false;
917 14 int ysign = dy.sign();
918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 while(scr_canmove(0, ysign, special, kb, ign_sv))
919 {
920 y += ysign;
921 dy -= ysign;
922 }
923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(dy)
924 {
925 14 dy.doDecBound(0,-9999, 0,9999);
926
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
224 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(scr_canmove(0, val, special, kb, ign_sv))
928 {
929 retval = val;
930 return BSEARCH_CONTINUE_AWAY0;
931 }
932 210 else return BSEARCH_CONTINUE_TOWARD0;
933 210 });
934 14 y += dy;
935 14 }
936 }
937 200 }
938 1310 return ret;
939 1311 }
940
941 754 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
942 {
943
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
754 static const zfix diagrate = zslongToFix(7071);
944
5/13
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 754 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 479 times.
✓ Branch 7 taken 259 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
754 switch(NORMAL_DIR(dir))
945 {
946 case up:
947 return movexy(0, -px, special, kb, false, earlyret);
948 case down:
949 16 return movexy(0, px, special, kb, false, earlyret);
950 case left:
951 479 return movexy(-px, 0, special, kb, false, earlyret);
952 case right:
953 259 return movexy(px, 0, special, kb, false, earlyret);
954 case r_up:
955 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
956 case r_down:
957 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
958 case l_up:
959 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
960 case l_down:
961 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
962 }
963 return false;
964 754 }
965
966 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
967 {
968 double v = degrees.getFloat() * PI / 180.0;
969 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
970 return movexy(dx, dy, special, kb, false, earlyret);
971 }
972
973 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
974 {
975 zfix tx = x, ty = y;
976 bool ret = movexy(dx, dy, special, kb, false, true);
977 x = tx;
978 y = ty;
979 return ret;
980 }
981 754 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
982 {
983 754 zfix tx = x, ty = y;
984 754 bool ret = moveDir(dir, px, special, kb, true);
985 754 x = tx;
986 754 y = ty;
987 754 return ret;
988 }
989 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
990 {
991 zfix tx = x, ty = y;
992 bool ret = moveAtAngle(degrees, px, special, kb, true);
993 x = tx;
994 y = ty;
995 return ret;
996 }
997
998 // Handle pitfalls
999 37823959 bool enemy::do_falling(int32_t index)
1000 {
1001
2/2
✓ Branch 0 taken 37821661 times.
✓ Branch 1 taken 2298 times.
37823959 if(fallclk > 0)
1002 {
1003
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 2265 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 20 times.
2298 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
1004
2/2
✓ Branch 0 taken 2276 times.
✓ Branch 1 taken 22 times.
2298 if(!--fallclk)
1005 {
1006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(immortal) //Keep alive forever
1007 ++fallclk; //force another frame of falling.... forever.
1008
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(dying) //Give 1 frame for script revival
1009 {
1010
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(flags&guy_never_return)
1011 never_return(index);
1012
1013
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(leader)
1014 kill_em_all();
1015
1016 //leave_item(); //Don't drop items in pits!
1017 11 stop_bgsfx(index);
1018 11 return true;
1019 }
1020 else
1021 {
1022 11 try_death(true); //Force death
1023 11 ++fallclk; //force another frame of falling
1024 }
1025 11 }
1026
1027 2287 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1028 2287 cs = spr.csets & 0xF;
1029
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 int32_t fr = spr.frames ? spr.frames : 1;
1030
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 int32_t spd = spr.speed ? spr.speed : 1;
1031 2287 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1032
2/2
✓ Branch 0 taken 1101 times.
✓ Branch 1 taken 1186 times.
2287 tile = spr.tile + zc_min(animclk / spd, fr-1);
1033 2287 }
1034 37823948 return false;
1035 37823959 }
1036
1037 // Handle drowning in water
1038 37821661 bool enemy::do_drowning(int32_t index)
1039 {
1040
1/2
✓ Branch 0 taken 37821661 times.
✗ Branch 1 not taken.
37821661 if(drownclk > 0)
1041 {
1042 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
1043 //!TODO: Drown SFX
1044 if(!--drownclk)
1045 {
1046 if(immortal) //Keep alive forever
1047 ++drownclk; //force another frame of falling.... forever.
1048 else if(dying) //Give 1 frame for script revival
1049 {
1050 if(flags&guy_never_return)
1051 never_return(index);
1052
1053 if(leader)
1054 kill_em_all();
1055
1056 //leave_item(); //Don't drop items in pits!
1057 stop_bgsfx(index);
1058 return true;
1059 }
1060 else
1061 {
1062 try_death(true); //Force death
1063 ++drownclk; //force another frame of falling
1064 }
1065 }
1066
1067 if (drownCombo && combobuf[drownCombo].usrflags&cflag1)
1068 {
1069 wpndata &spr = wpnsbuf[QMisc.sprites[sprLAVADROWN]];
1070 cs = spr.csets & 0xF;
1071 int32_t fr = spr.frames ? spr.frames : 1;
1072 int32_t spd = spr.speed ? spr.speed : 1;
1073 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1074 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1075 }
1076 else
1077 {
1078 wpndata &spr = wpnsbuf[QMisc.sprites[sprDROWN]];
1079 cs = spr.csets & 0xF;
1080 int32_t fr = spr.frames ? spr.frames : 1;
1081 int32_t spd = spr.speed ? spr.speed : 1;
1082 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1083 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1084 }
1085 }
1086 37821661 return false;
1087 37821661 }
1088
1089 // Supplemental animation code that all derived classes should call
1090 // as a return value for animate().
1091 // Handles the death animation and returns true when enemy is finished.
1092 38486231 bool enemy::Dead(int32_t index)
1093 {
1094
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 38484402 times.
38486231 if(immortal)
1095 {
1096 1829 dying = false;
1097 1829 return false;
1098 }
1099
2/2
✓ Branch 0 taken 762989 times.
✓ Branch 1 taken 37721413 times.
38484402 if(dying)
1100 {
1101
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 762988 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
762989 if(deathexstate > -1 && deathexstate < 32)
1102 {
1103 1 setxmapflag(1<<deathexstate);
1104 1 deathexstate = -1;
1105 1 }
1106 762989 --clk2;
1107
1108
4/4
✓ Branch 0 taken 723363 times.
✓ Branch 1 taken 39626 times.
✓ Branch 2 taken 38635 times.
✓ Branch 3 taken 3195 times.
762989 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1109
2/2
✓ Branch 0 taken 41830 times.
✓ Branch 1 taken 681533 times.
723363 && hp>-1000) // not killed by ringleader
1110 38635 death_sfx();
1111
1112
2/2
✓ Branch 0 taken 719613 times.
✓ Branch 1 taken 43376 times.
762989 if(clk2==0)
1113 {
1114
2/2
✓ Branch 0 taken 42672 times.
✓ Branch 1 taken 704 times.
43376 if(flags&guy_never_return)
1115 704 never_return(index);
1116
1117
2/2
✓ Branch 0 taken 43305 times.
✓ Branch 1 taken 71 times.
43376 if(leader)
1118 71 kill_em_all();
1119
1120 43376 leave_item();
1121 43376 }
1122
1123 762989 stop_bgsfx(index);
1124 762989 return (clk2==0);
1125 }
1126
1127 37721413 return false;
1128 38486231 }
1129
1130 // Basic animation code that all derived classes should call.
1131 // The one with an index is the one that is called by
1132 // the guys sprite list; index is the enemy's index in the list.
1133 37824215 bool enemy::animate(int32_t index)
1134 {
1135
2/2
✓ Branch 0 taken 1683411 times.
✓ Branch 1 taken 36140804 times.
37824215 if(sclk <= 0) hitdir = -1;
1136
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 37823959 times.
37824215 if(switch_hooked)
1137 {
1138
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1139 {
1140 //Run its script
1141 if (!didScriptThisFrame)
1142 {
1143 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1144 {
1145 return 0; //Avoid NULLPO if this object deleted itself
1146 }
1147 }
1148 }
1149 256 return false;
1150 }
1151
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 37823948 times.
37823959 if(do_falling(index)) return true;
1152
2/2
✓ Branch 0 taken 2287 times.
✓ Branch 1 taken 37821661 times.
37823948 else if(fallclk)
1153 {
1154 //clks
1155
2/2
✓ Branch 0 taken 1611 times.
✓ Branch 1 taken 676 times.
2287 if(hclk>0)
1156 676 --hclk;
1157
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 if(stunclk>0)
1158 --stunclk;
1159
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 if ( frozenclock > 0 )
1160 --frozenclock;
1161
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 if(hashero)
1162 {
1163 Hero.setX(x);
1164 Hero.setY(y);
1165 Hero.fallCombo = fallCombo;
1166 Hero.fallclk = fallclk;
1167 hashero = false; //Let Hero go if falling
1168 }
1169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2287 times.
2287 if (!didScriptThisFrame)
1170 {
1171 2287 run_script(MODE_NORMAL);
1172 2287 }
1173 2287 return false;
1174 }
1175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37821661 times.
37821661 if(do_drowning(index)) return true;
1176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37821661 times.
37821661 else if(drownclk)
1177 {
1178 //clks
1179 if(hclk>0)
1180 --hclk;
1181 if(stunclk>0)
1182 --stunclk;
1183 if ( frozenclock > 0 )
1184 --frozenclock;
1185 if(hashero)
1186 {
1187 Hero.setX(x);
1188 Hero.setY(y);
1189 Hero.drownclk = drownclk;
1190 hashero = false; //Let Hero go if falling
1191 }
1192 if (!didScriptThisFrame)
1193 {
1194 run_script(MODE_NORMAL);
1195 }
1196 return false;
1197 }
1198 37821661 int32_t nx = real_x(x);
1199 37821661 int32_t ny = real_y(y);
1200
1201
4/4
✓ Branch 0 taken 27354947 times.
✓ Branch 1 taken 10466714 times.
✓ Branch 2 taken 5643282 times.
✓ Branch 3 taken 21711665 times.
37821661 if(ox!=nx || oy!=ny)
1202 {
1203 16109996 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1204 16109996 }
1205
1206 37821661 ox = nx;
1207 37821661 oy = ny;
1208
1209 // Maybe they fell off the bottom in sideview, or were moved by a script.
1210
1211 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1212
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 37819832 times.
37821661 if ( immortal )
1213 {
1214 //skip, as it can go out of bounds, from immortality
1215 1829 }
1216
2/6
✓ Branch 0 taken 37819832 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37819832 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
37819832 else if ( (moveflags & move_ignore_screenedge) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1217 {
1218 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1219 }
1220
9/10
✓ Branch 0 taken 37423739 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 37818827 times.
✓ Branch 3 taken 1005 times.
✓ Branch 4 taken 37788803 times.
✓ Branch 5 taken 30024 times.
✓ Branch 6 taken 37788803 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 51 times.
✓ Branch 9 taken 37788752 times.
37819832 else if ( (OUTOFBOUNDS) )
1221 {
1222 31080 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1223 31080 }
1224 //fall down
1225
6/6
✓ Branch 0 taken 27134533 times.
✓ Branch 1 taken 10687128 times.
✓ Branch 2 taken 10419698 times.
✓ Branch 3 taken 27401963 times.
✓ Branch 4 taken 506382 times.
✓ Branch 5 taken 9913316 times.
37821661 if((enemycanfall(id) || (moveflags & move_obeys_grav) )&& fading != fade_flicker && clk>=0)
1226 {
1227
2/2
✓ Branch 0 taken 303574 times.
✓ Branch 1 taken 9609742 times.
9913316 if(isSideViewGravity())
1228 {
1229
1/2
✓ Branch 0 taken 303574 times.
✗ Branch 1 not taken.
303574 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1230 {
1231
2/2
✓ Branch 0 taken 176339 times.
✓ Branch 1 taken 127235 times.
303574 if(!isOnSideviewPlatform())
1232 {
1233 127235 bool willHitSVPlatform = false;
1234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH)?hit_width:16;
1235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT)?hit_height:16;
1236
2/2
✓ Branch 0 taken 127235 times.
✓ Branch 1 taken 127235 times.
254470 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1237 {
1238
5/8
✓ Branch 0 taken 23361 times.
✓ Branch 1 taken 103874 times.
✓ Branch 2 taken 23361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23361 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 127235 times.
✗ Branch 7 not taken.
127235 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1239 {
1240 willHitSVPlatform = true;
1241 break;
1242 }
1243 127235 }
1244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 if(willHitSVPlatform)
1245 {
1246 y+=fall/100;
1247 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1248 do_fix(y, 16); //Fix to top of SV Ladder
1249 fall = 0;
1250 }
1251 else
1252 {
1253 127235 y+=fall/100;
1254
2/2
✓ Branch 0 taken 17808 times.
✓ Branch 1 taken 109427 times.
127235 if(fall <= (int32_t)zinit.terminalv)
1255 109427 fall += (zinit.gravity/100);
1256 }
1257 127235 }
1258 else
1259 {
1260
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 176072 times.
176339 if(fall!=0) // Only fix pos once
1261 {
1262 //y-=(int32_t)y%8; // Fix position
1263 267 do_fix(y, 8); //Fix position
1264 267 }
1265
1266 176339 fall = 0;
1267 }
1268 303574 }
1269 else
1270 {
1271 if(isOnSideviewPlatform())
1272 fall = 0;
1273 else
1274 {
1275 zfix fall_amnt = fall/100;
1276 bool hit = false;
1277 while(fall_amnt >= 1)
1278 {
1279 --fall_amnt;
1280 ++y;
1281 if(isOnSideviewPlatform())
1282 {
1283 y = y.getInt();
1284 fall_amnt = 0;
1285 hit = true;
1286 break;
1287 }
1288 }
1289 if(fall_amnt > 0)
1290 y += fall_amnt;
1291 if(fall_amnt < 0)
1292 {
1293 if(!movexy(0,fall_amnt,spw_none,false,!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)))
1294 hit = true;
1295 }
1296 if(hit)
1297 fall = 0;
1298 else if(fall <= (int32_t)zinit.terminalv)
1299 fall += (zinit.gravity/100);
1300 }
1301 }
1302 303574 }
1303 else
1304 {
1305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9609742 times.
9609742 if (!(moveflags & move_no_fake_z))
1306 {
1307
2/2
✓ Branch 0 taken 5056840 times.
✓ Branch 1 taken 4552902 times.
9609742 if(fakefall!=0)
1308 4552902 fakez-=(fakefall/100);
1309
1310
2/2
✓ Branch 0 taken 4552902 times.
✓ Branch 1 taken 5056840 times.
9609742 if(fakez<0)
1311 4552902 fakez = fakefall = 0;
1312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5056840 times.
5056840 else if(fakefall <= (int32_t)zinit.terminalv)
1313 5056840 fakefall += (zinit.gravity/100);
1314
1315
5/6
✓ Branch 0 taken 9609742 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5056840 times.
✓ Branch 3 taken 4552902 times.
✓ Branch 4 taken 4567130 times.
✓ Branch 5 taken 489710 times.
9609742 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1316 9609742 }
1317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9609742 times.
9609742 if (!(moveflags & move_no_real_z))
1318 {
1319
2/2
✓ Branch 0 taken 5477877 times.
✓ Branch 1 taken 4131865 times.
9609742 if(fall!=0)
1320 4131865 z-=(fall/100);
1321
1322
2/2
✓ Branch 0 taken 4118583 times.
✓ Branch 1 taken 5491159 times.
9609742 if(z<0)
1323 4118583 z = fall = 0;
1324
2/2
✓ Branch 0 taken 9167 times.
✓ Branch 1 taken 5481992 times.
5491159 else if(fall <= (int32_t)zinit.terminalv)
1325 5481992 fall += (zinit.gravity/100);
1326
1327
6/6
✓ Branch 0 taken 9568838 times.
✓ Branch 1 taken 40904 times.
✓ Branch 2 taken 5450255 times.
✓ Branch 3 taken 4118583 times.
✓ Branch 4 taken 4962352 times.
✓ Branch 5 taken 487903 times.
9609742 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1328 9609742 }
1329
1330 }
1331 9913316 }
1332
4/4
✓ Branch 0 taken 37425568 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 9193428 times.
✓ Branch 3 taken 28232140 times.
37821661 if(!isSideViewGravity() && (moveflags & move_can_pitfall))
1333 {
1334
8/10
✓ Branch 0 taken 9167028 times.
✓ Branch 1 taken 26400 times.
✓ Branch 2 taken 9127370 times.
✓ Branch 3 taken 39658 times.
✓ Branch 4 taken 9127370 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 9167028 times.
✓ Branch 8 taken 9127370 times.
✓ Branch 9 taken 9127370 times.
9193428 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1335 {
1336 9127370 fallCombo = check_pits();
1337 9127370 }
1338 27448168 }
1339
4/4
✓ Branch 0 taken 37425568 times.
✓ Branch 1 taken 18650833 times.
✓ Branch 2 taken 146615 times.
✓ Branch 3 taken 37278953 times.
56076401 if(!isSideViewGravity() && (moveflags & move_can_waterdrown))
1340 {
1341
8/10
✓ Branch 0 taken 142669 times.
✓ Branch 1 taken 3946 times.
✓ Branch 2 taken 141616 times.
✓ Branch 3 taken 1053 times.
✓ Branch 4 taken 141616 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 142669 times.
✓ Branch 8 taken 141616 times.
✓ Branch 9 taken 141616 times.
146615 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1342 {
1343 141616 drownCombo = check_water();
1344 141616 }
1345 429847 }
1346
1347 56359633 runKnockback(); //scripted knockback handling
1348
1349 // clk is incremented here
1350
2/2
✓ Branch 0 taken 54055093 times.
✓ Branch 1 taken 2304540 times.
56359633 if(++clk >= frate)
1351 2304540 clk=0;
1352
1353 // hit and death handling
1354
2/2
✓ Branch 0 taken 1240301 times.
✓ Branch 1 taken 55119332 times.
56359633 if(hclk>0)
1355 1240301 --hclk;
1356
1357
2/2
✓ Branch 0 taken 676239 times.
✓ Branch 1 taken 55683394 times.
56359633 if(stunclk>0)
1358 676239 --stunclk;
1359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56359633 times.
56359633 if ( frozenclock > 0 )
1360 --frozenclock;
1361
1362
5/6
✓ Branch 0 taken 13488 times.
✓ Branch 1 taken 56346145 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 13382 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 106 times.
56359633 if(ceiling && z <= 0 && fakez <= 0)
1363 106 ceiling = false;
1364
1365 56359633 try_death();
1366
1367 56359633 scored=false;
1368
1369 56359633 ++c_clk;
1370
1371 //Run its script
1372
2/2
✓ Branch 0 taken 18562789 times.
✓ Branch 1 taken 37796844 times.
56359633 if (!didScriptThisFrame)
1373 {
1374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37796844 times.
37796844 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1375 {
1376 return 0; //Avoid NULLPO if this object deleted itself
1377 }
1378 37796844 }
1379
1380 // returns true when enemy is defeated
1381 56359633 return Dead(index);
1382 56362187 }
1383
1384 38576082 bool enemy::setSolid(bool set)
1385 {
1386
1/2
✓ Branch 0 taken 38576082 times.
✗ Branch 1 not taken.
38576082 bool actual = set && !isSubmerged();
1387 38576082 bool ret = solid_object::setSolid(actual);
1388 38576082 solid = set;
1389 38576082 return ret;
1390 }
1391 void enemy::doContactDamage(int32_t hdir)
1392 {
1393 Hero.hithero(guys.find(this), hdir);
1394 }
1395
1396 22405 void enemy::solid_push(solid_object *obj)
1397 {
1398
1/2
✓ Branch 0 taken 22405 times.
✗ Branch 1 not taken.
22405 if(obj == this) return; //can't push self
1399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22405 times.
22405 if(moveflags&move_not_pushable) return; //not pushable
1400 22405 zfix dx, dy;
1401 22405 int32_t hdir = -1;
1402 22405 solid_push_int(obj,dx,dy,hdir,true);
1403
1404
4/4
✓ Branch 0 taken 22292 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 22142 times.
22405 if(!dx && !dy) return;
1405
1406 263 bool t = obj->getTempNonsolid();
1407 263 obj->setTempNonsolid(true);
1408
1409 263 int32_t ydir = dy > 0 ? down : up;
1410 263 int32_t xdir = dx > 0 ? right : left;
1411
1412 263 auto special = isflier(id) ? spw_floater : spw_none;
1413
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 7 times.
263 if(!movexy(dx,dy,special,true,true))
1414 {
1415 //Crushed?
1416 7 }
1417
1418 263 obj->setTempNonsolid(t);
1419 22405 }
1420 22405 bool enemy::is_unpushable() const
1421 {
1422 22405 return isSubmerged();
1423 }
1424 22087 bool enemy::sideview_mode() const
1425 {
1426
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22087 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22087 return isSideViewGravity() && (moveflags&move_obeys_grav) && !(moveflags&move_not_pushable);
1427 }
1428
1429 3234 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1430 {
1431 3234 int32_t yg = (special==spw_floater)?8:0;
1432 3234 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1433
1434
8/10
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 870 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 870 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2368 times.
✓ Branch 9 taken 3238 times.
3234 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1435 4732 return true;
1436
1437 3238 bool isInDungeon = isdungeon();
1438
3/4
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 2976 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 262 times.
3238 if(isInDungeon || special==spw_wizzrobe)
1439 {
1440
7/8
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 604 times.
✓ Branch 5 taken 1779 times.
✓ Branch 6 taken 604 times.
✗ Branch 7 not taken.
2976 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1441 1199 return true;
1442
1443
7/8
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 1187 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 595 times.
✓ Branch 5 taken 595 times.
✓ Branch 6 taken 595 times.
✗ Branch 7 not taken.
1779 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1444
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1190 if(special!=spw_door) // walk in door way
1445 return true;
1446 595 }
1447
1448
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
857 if(!(moveflags & move_can_pitwalk) && !(moveflags & move_can_pitfall)) //Don't walk into pits (knockback doesn't call this func)
1449 {
1450
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1451
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1452 return true;
1453 62 }
1454
1455
1/4
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
857 switch(special)
1456 {
1457 case spw_clipbottomright:
1458 if(dy>=128 || dx>=208) return true;
1459 break;
1460 case spw_clipright:
1461 break; //if(x>=208) return true; break;
1462
1463 case spw_wizzrobe: // fall through
1464 case spw_floater: // Special case for fliers and wizzrobes - hack!
1465 {
1466
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 595 times.
857 if(isInDungeon)
1467 {
1468
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dy < 32-yg || dy >= 144) return true;
1469
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dx < 32 || dx >= 224) return true;
1470 595 }
1471 857 return false;
1472 }
1473 }
1474
1475 dx&=(special==spw_halfstep)?(~7):(~15);
1476 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1477
1478 if(special==spw_water)
1479 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1480
1481 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1482 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1483 870 }
1484
1485 6575 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1486 {
1487 6575 bool kb = false;
1488 6575 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1489
1490
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6575 times.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6575 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6575 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6575 times.
6575 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=240+nb || dy>=160+nb)
1491 return true;
1492
1493
2/2
✓ Branch 0 taken 5062 times.
✓ Branch 1 taken 1513 times.
6575 if(isdungeon())
1494 {
1495
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dy<32) || (dy>=144))
1496 return true;
1497
1498
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dx<32) || (dx>=224))
1499 return true;
1500 1513 }
1501
1502
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
6575 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall))) //Don't walk into pits, unless being knocked back
1503 {
1504
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
13150 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1505
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
6575 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1506 return true;
1507 6575 }
1508
1509
2/2
✓ Branch 0 taken 6545 times.
✓ Branch 1 taken 30 times.
6575 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1510 {
1511
3/4
✓ Branch 0 taken 2657 times.
✓ Branch 1 taken 3888 times.
✓ Branch 2 taken 2657 times.
✗ Branch 3 not taken.
9202 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2657 times.
2657 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1513 }
1514 else
1515 {
1516
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1517
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1518
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1520 }
1521 6575 }
1522
1523 32455575 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1524 {
1525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32455575 times.
32455575 if(moveflags & move_new_movement)
1526 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1527 32455575 int32_t yg = (special==spw_floater)?8:0;
1528 32455575 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1529
2/2
✓ Branch 0 taken 3703963 times.
✓ Branch 1 taken 28751612 times.
32455575 switch(dir)
1530 {
1531 case l_down:
1532 case r_down:
1533 case down:
1534 case 11: //r_down
1535 case 12: //down
1536 case 13: //l_down
1537 {
1538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3703963 times.
3703963 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1539 {
1540
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3703955 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
3703963 if ( SIZEflags&OVERRIDE_HIT_HEIGHT && !isflier(id) )
1541 {
1542 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1543
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 dy += zc_max(hit_height-16,0);
1544 8 }
1545 3703963 }
1546 3703963 break;
1547 }
1548 }
1549
2/2
✓ Branch 0 taken 3704751 times.
✓ Branch 1 taken 28750824 times.
32455575 switch(dir)
1550 {
1551 case r_up:
1552 case r_down:
1553 case right:
1554 case 9: //r_up
1555 case 10: //right
1556 case 11: //r_down
1557 {
1558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3704751 times.
3704751 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1559 {
1560
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3704748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3704751 if ( SIZEflags&OVERRIDE_HIT_WIDTH && !isflier(id) )
1561 {
1562 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1563
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dx += zc_max(hit_width-16,0);
1564 3 }
1565 3704751 }
1566 3704751 break;
1567 }
1568 }
1569 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
1570
1571
10/10
✓ Branch 0 taken 22401614 times.
✓ Branch 1 taken 10053961 times.
✓ Branch 2 taken 8752343 times.
✓ Branch 3 taken 1301618 times.
✓ Branch 4 taken 10016882 times.
✓ Branch 5 taken 37079 times.
✓ Branch 6 taken 9993755 times.
✓ Branch 7 taken 23127 times.
✓ Branch 8 taken 22454486 times.
✓ Branch 9 taken 32448241 times.
32455575 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1572 44916306 return true;
1573
1574 32448241 bool isInDungeon = isdungeon();
1575
4/4
✓ Branch 0 taken 3927110 times.
✓ Branch 1 taken 28521131 times.
✓ Branch 2 taken 11756 times.
✓ Branch 3 taken 3915354 times.
32448241 if(isInDungeon || special==spw_wizzrobe)
1576 {
1577
8/8
✓ Branch 0 taken 5892066 times.
✓ Branch 1 taken 22640821 times.
✓ Branch 2 taken 5667599 times.
✓ Branch 3 taken 224467 times.
✓ Branch 4 taken 5820182 times.
✓ Branch 5 taken 17045106 times.
✓ Branch 6 taken 5819995 times.
✓ Branch 7 taken 187 times.
28532887 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=144 && dy>=144))
1578 11487594 return true;
1579
1580
8/8
✓ Branch 0 taken 5739703 times.
✓ Branch 1 taken 11305590 times.
✓ Branch 2 taken 5573250 times.
✓ Branch 3 taken 166453 times.
✓ Branch 4 taken 5688164 times.
✓ Branch 5 taken 5783879 times.
✓ Branch 6 taken 5687210 times.
✓ Branch 7 taken 954 times.
17045293 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<224 && dx>=224))
1581
2/2
✓ Branch 0 taken 113866 times.
✓ Branch 1 taken 94 times.
11260460 if(special!=spw_door) // walk in door way
1582 113866 return true;
1583 5784927 }
1584
1585
6/6
✓ Branch 0 taken 3100315 times.
✓ Branch 1 taken 6599966 times.
✓ Branch 2 taken 750003 times.
✓ Branch 3 taken 2350312 times.
✓ Branch 4 taken 51230 times.
✓ Branch 5 taken 698773 times.
9700281 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
1586 {
1587
4/4
✓ Branch 0 taken 3042668 times.
✓ Branch 1 taken 6417 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 3041716 times.
6090851 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1588
4/4
✓ Branch 0 taken 3042485 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 3041766 times.
✓ Branch 3 taken 719 times.
3042668 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1589 7369 return true;
1590 3041716 }
1591
1592
4/4
✓ Branch 0 taken 7508153 times.
✓ Branch 1 taken 2178505 times.
✓ Branch 2 taken 973 times.
✓ Branch 3 taken 5281 times.
9692912 switch(special)
1593 {
1594 case spw_clipbottomright:
1595
4/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 187 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 707 times.
973 if(dy>=128 || dx>=208) return true;
1596 707 break;
1597 case spw_clipright:
1598 5281 break; //if(input_x>=208) return true; break;
1599
1600 case spw_wizzrobe: // fall through
1601 case spw_floater: // Special case for fliers and wizzrobes - hack!
1602 {
1603
2/2
✓ Branch 0 taken 2866474 times.
✓ Branch 1 taken 4641679 times.
7508153 if(isInDungeon)
1604 {
1605
3/4
✓ Branch 0 taken 4641667 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4641667 times.
4641679 if(dy < 32-yg || dy >= 144) return true;
1606
4/4
✓ Branch 0 taken 4639555 times.
✓ Branch 1 taken 2112 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4639539 times.
4641667 if(dx < 32 || dx >= 224) return true;
1607 4639539 }
1608 7506013 return false;
1609 }
1610 }
1611
1612 2184493 dx&=(special==spw_halfstep)?(~7):(~15);
1613
2/2
✓ Branch 0 taken 486587 times.
✓ Branch 1 taken 1697906 times.
2184493 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1614
1615
2/2
✓ Branch 0 taken 414391 times.
✓ Branch 1 taken 1770102 times.
2184493 if(special==spw_water)
1616
2/2
✓ Branch 0 taken 16741 times.
✓ Branch 1 taken 397650 times.
414391 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1617
1618
2/2
✓ Branch 0 taken 1711234 times.
✓ Branch 1 taken 58868 times.
1770102 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1619 {
1620
4/4
✓ Branch 0 taken 1227843 times.
✓ Branch 1 taken 483391 times.
✓ Branch 2 taken 1217806 times.
✓ Branch 3 taken 10037 times.
2929040 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1621
2/2
✓ Branch 0 taken 14580 times.
✓ Branch 1 taken 1203226 times.
1217806 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1622 }
1623 else
1624 {
1625
4/4
✓ Branch 0 taken 42375 times.
✓ Branch 1 taken 16493 times.
✓ Branch 2 taken 42111 times.
✓ Branch 3 taken 264 times.
100979 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1626
3/4
✓ Branch 0 taken 41748 times.
✓ Branch 1 taken 363 times.
✓ Branch 2 taken 41748 times.
✗ Branch 3 not taken.
42111 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1627
4/4
✓ Branch 0 taken 36513 times.
✓ Branch 1 taken 5235 times.
✓ Branch 2 taken 36498 times.
✓ Branch 3 taken 15 times.
41748 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1628
2/2
✓ Branch 0 taken 36195 times.
✓ Branch 1 taken 303 times.
36498 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1629 }
1630 10079621 }
1631
1632 383430 bool enemy::isOnSideviewPlatform()
1633 {
1634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
1635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1636
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
383430 if(!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)&&fall<0)
1637 return false;
1638
5/6
✓ Branch 0 taken 10306 times.
✓ Branch 1 taken 373124 times.
✓ Branch 2 taken 211 times.
✓ Branch 3 taken 10095 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 211 times.
383430 if(y + usehei >= 176 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true; //Bottom of the map
1639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383219 times.
383219 if(check_slope(x, y+1, usewid, usehei)) return true;
1640
2/2
✓ Branch 0 taken 383219 times.
✓ Branch 1 taken 168001 times.
551220 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1641 {
1642
2/2
✓ Branch 0 taken 168001 times.
✓ Branch 1 taken 215218 times.
383219 if(_walkflag(nx,y+usehei,1)) return true;
1643
3/4
✓ Branch 0 taken 168001 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120644 times.
✓ Branch 3 taken 47357 times.
168001 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47357 times.
47357 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1645 47357 }
1646 168001 return false;
1647 383430 }
1648
1649 // Stops playing the given sound only if there are no enemies left to play it
1650 765900 void enemy::stop_bgsfx(int32_t index)
1651 {
1652
2/2
✓ Branch 0 taken 750790 times.
✓ Branch 1 taken 15110 times.
765900 if(bgsfx<=0)
1653 750790 return;
1654
1655 // Look for other enemies with the same bgsfx
1656
2/2
✓ Branch 0 taken 52994 times.
✓ Branch 1 taken 8806 times.
61800 for(int32_t i=0; i<guys.Count(); i++)
1657 {
1658
4/4
✓ Branch 0 taken 41902 times.
✓ Branch 1 taken 11092 times.
✓ Branch 2 taken 6304 times.
✓ Branch 3 taken 35598 times.
52994 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1659 6304 return;
1660 46690 }
1661
1662 8806 stop_sfx(bgsfx);
1663 765900 }
1664
1665
1666 // to allow for different sfx on defeating enemy
1667 40243 void enemy::death_sfx()
1668 {
1669
2/2
✓ Branch 0 taken 39959 times.
✓ Branch 1 taken 284 times.
40243 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
1670 40243 }
1671
1672 void enemy::move(zfix dx,zfix dy)
1673 {
1674 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1675 {
1676 switch(family)
1677 {
1678 case eeFIRE:
1679 case eeOTHER:
1680 return;
1681 default: break;
1682 }
1683 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1684 }
1685 */
1686 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & move_obeys_grav) || !enemycanfall(id)))
1687 {
1688 x+=dx;
1689 y+=dy;
1690 }
1691 }
1692
1693 18325627 void enemy::move(zfix s)
1694 {
1695 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1696 {
1697 switch(family)
1698 {
1699 case eeFIRE:
1700 case eeOTHER:
1701 return;
1702 default: break;
1703 }
1704 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1705 }*/
1706
9/10
✓ Branch 0 taken 18325588 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 79762 times.
✓ Branch 3 taken 18245826 times.
✓ Branch 4 taken 40724 times.
✓ Branch 5 taken 39038 times.
✓ Branch 6 taken 855 times.
✓ Branch 7 taken 39869 times.
✓ Branch 8 taken 855 times.
✗ Branch 9 not taken.
18325627 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & move_obeys_grav)))
1707 {
1708 18324733 sprite::move(s);
1709 18324733 }
1710 18325627 }
1711
1712 43678 void enemy::leave_item()
1713 {
1714 43678 int32_t drop_item = select_dropitem(item_set, x, y);
1715 43678 int32_t thedropset = item_set;
1716
1717 43678 std::vector<int32_t> &ev = FFCore.eventData;
1718 43678 ev.clear();
1719 43678 ev.push_back(getUID());
1720 43678 ev.push_back(drop_item*10000);
1721 43678 ev.push_back(thedropset*10000);
1722
1723 43678 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1724 43678 drop_item = vbound(ev[1] / 10000,-2,255);
1725 43678 thedropset = ev[2] / 10000;
1726 43678 ev.clear();
1727
1/2
✓ Branch 0 taken 43678 times.
✗ Branch 1 not taken.
43678 if(drop_item == -2)
1728 {
1729 drop_item = select_dropitem(thedropset,x,y);
1730 }
1731
1732
6/6
✓ Branch 0 taken 16429 times.
✓ Branch 1 taken 27249 times.
✓ Branch 2 taken 917 times.
✓ Branch 3 taken 15512 times.
✓ Branch 4 taken 169 times.
✓ Branch 5 taken 748 times.
43678 if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1733 {
1734 item* itm;
1735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16260 times.
16260 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1736 {
1737 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1738 }
1739 else
1740 {
1741
8/14
✓ Branch 0 taken 1629 times.
✓ Branch 1 taken 14631 times.
✓ Branch 2 taken 1629 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1629 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1629 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1629 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1629 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1629 times.
✗ Branch 13 not taken.
16260 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1742
4/8
✓ Branch 0 taken 14631 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14631 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14631 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14631 times.
✗ Branch 7 not taken.
14631 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1743 }
1744 16260 itm->from_dropset = thedropset;
1745 16260 items.add(itm);
1746
1747 16260 ev.push_back(getUID());
1748 16260 ev.push_back(itm->getUID());
1749
1750 16260 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1751 16260 ev.clear();
1752 16260 }
1753 43678 }
1754
1755 // auomatically kill off enemy (for rooms with ringleaders)
1756 397 void enemy::kickbucket()
1757 {
1758
3/4
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 365 times.
✗ Branch 3 not taken.
397 if(!superman && !(flags&guy_ignore_kill_all))
1759 365 hp=-1000; // don't call death_sfx()
1760 397 }
1761
1762 21250 bool enemy::isSubmerged() const
1763 {
1764 21250 return submerged;
1765 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1766 }
1767
1768 20952 void enemy::FireBreath(bool seekhero)
1769 {
1770
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if(wpn==wNone)
1771 return;
1772
1773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20952 times.
20952 if(wpn==ewFireTrail)
1774 {
1775 dmisc1 = e1tEACHTILE;
1776 FireWeapon();
1777 return;
1778 }
1779
1780 20952 float fire_angle=0.0;
1781 20952 int32_t wx=0, wy=0, wdir=dir, xoff=0, yoff=0;
1782
1783
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1784 {
1785 xoff += hxofs;
1786 if (weapoverrideFLAGS & OVERRIDE_HIT_WIDTH)
1787 xoff += (hit_width / 2) - (weap_tilew * 8);
1788 else
1789 xoff += (hit_width / 2) - 8;
1790 }
1791
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1792 {
1793 yoff += hyofs;
1794 if (weapoverrideFLAGS & OVERRIDE_HIT_HEIGHT)
1795 yoff += (hit_height / 2) - (weap_tileh * 8);
1796 else
1797 yoff += (hit_height / 2) - 8;
1798 }
1799
1800
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 if(!seekhero)
1801 {
1802
4/5
✓ Branch 0 taken 3297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3079 times.
✓ Branch 3 taken 5287 times.
✓ Branch 4 taken 4208 times.
15871 switch(dir)
1803 {
1804 case down:
1805 3079 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1806 3079 wx=x;
1807 3079 wy=y+8;
1808 3079 break;
1809
1810 case -1:
1811 case up:
1812 3297 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1813 3297 wx=x;
1814 3297 wy=y-8;
1815 3297 break;
1816
1817 case left:
1818 5287 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1819 5287 wx=x-8;
1820 5287 wy=y;
1821 5287 break;
1822
1823 case right:
1824 4208 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1825 4208 wx=x+8;
1826 4208 wy=y;
1827 4208 break;
1828 }
1829
1830
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 15735 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
15871 if(wpn==ewFlame || wpn==ewFlame2)
1831 {
1832
2/4
✓ Branch 0 taken 15735 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15735 times.
15735 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==-PI/2) wdir=up;
1834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==PI/2) wdir=down;
1835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==0) wdir=right;
1836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<-PI/2) wdir=l_up;
1837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<0) wdir=r_up;
1838
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14237 times.
15735 else if(fire_angle<(PI/2)) wdir=r_down;
1839
2/2
✓ Branch 0 taken 10121 times.
✓ Branch 1 taken 4116 times.
14237 else if(fire_angle<PI) wdir=l_down;
1840 15735 }
1841 15871 }
1842 else
1843 {
1844 5081 wx = x;
1845 5081 wy = y;
1846 }
1847
1848
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 addEwpn(wx+xoff,wy+yoff,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1849 20952 sfx(wpnsfx(wpn),pan(int32_t(x)));
1850
1851 20952 int32_t i=Ewpns.Count()-1;
1852 20952 weapon *ew = (weapon*)(Ewpns.spr(i));
1853 20952 ew->moveflags &= ~move_can_pitfall; //No falling in pits
1854
1855
4/4
✓ Branch 0 taken 15871 times.
✓ Branch 1 taken 5081 times.
✓ Branch 2 taken 7914 times.
✓ Branch 3 taken 7957 times.
20952 if(!seekhero && (zc_oldrand()&4))
1856 {
1857 7957 ew->angular=true;
1858 7957 ew->angle=fire_angle;
1859 7957 }
1860
1861
4/4
✓ Branch 0 taken 20676 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 20359 times.
20952 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1862 {
1863 20359 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20359 times.
20359 if ( ew->do_animation ) ew->tile+=ew->aframe;
1865 20359 }
1866
1867
2/2
✓ Branch 0 taken 20952 times.
✓ Branch 1 taken 766199 times.
787151 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1868 {
1869 766199 Ewpns.swap(j,j-1);
1870 766199 }
1871 20952 }
1872
1873 44653 void enemy::FireWeapon()
1874 {
1875 /*
1876 * Type:
1877 * 0x01: Boss fireball
1878 * 0x02: Seeks Hero
1879 * 0x04: Fast projectile
1880 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1881 */
1882
1883
2/2
✓ Branch 0 taken 44522 times.
✓ Branch 1 taken 131 times.
44653 if (wpn < 1) return;
1884
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 44522 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
44522 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1885 return;
1886
1887
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44522 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44522 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1888 dmisc1 = e1tEACHTILE;
1889
1890 44522 int32_t xoff = 0;
1891 44522 int32_t yoff = 0;
1892
1/2
✓ Branch 0 taken 44522 times.
✗ Branch 1 not taken.
44522 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1893 {
1894 xoff += hxofs;
1895 if (weapoverrideFLAGS & OVERRIDE_HIT_WIDTH)
1896 xoff += (hit_width / 2) - (weap_tilew * 8);
1897 else
1898 xoff += (hit_width / 2) - 8;
1899 }
1900
1/2
✓ Branch 0 taken 44522 times.
✗ Branch 1 not taken.
44522 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1901 {
1902 yoff += hyofs;
1903 if (weapoverrideFLAGS & OVERRIDE_HIT_HEIGHT)
1904 yoff += (hit_height / 2) - (weap_tileh * 8);
1905 else
1906 yoff += (hit_height / 2) - 8;
1907 }
1908
1909
5/8
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 41523 times.
✓ Branch 2 taken 1839 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 416 times.
✓ Branch 5 taken 98 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
44522 switch(dmisc1)
1910 {
1911 case e1t5SHOTS: //BS-Aquamentus
1912 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1913 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1914 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1915 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1916
1917 [[fallthrough]];
1918 case e1t3SHOTSFAST:
1919 case e1t3SHOTS: //Aquamentus
1920
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1921 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1922
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1923 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1924
1925 [[fallthrough]];
1926 default:
1927
12/20
✓ Branch 0 taken 42169 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42169 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42169 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42169 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 42169 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 42164 times.
✓ Branch 12 taken 42169 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18238 times.
✓ Branch 15 taken 23931 times.
✓ Branch 16 taken 42169 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 42169 times.
✗ Branch 19 not taken.
42169 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1928 42169 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1929 42169 sfx(wpnsfx(wpn),pan(int32_t(x)));
1930 42169 break;
1931
1932 case e1tSLANT:
1933 {
1934 416 int32_t slant = 0;
1935
1936
10/10
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 216 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 161 times.
✓ Branch 6 taken 61 times.
✓ Branch 7 taken 316 times.
✓ Branch 8 taken 138 times.
✓ Branch 9 taken 178 times.
416 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1937 246 slant = left;
1938
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 55 times.
✓ Branch 7 taken 86 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 61 times.
178 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1939 117 slant = right;
1940
1941
9/18
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 330 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 330 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 330 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 330 times.
✓ Branch 14 taken 330 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 330 times.
✗ Branch 17 not taken.
330 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1942 330 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1943 330 sfx(wpnsfx(wpn),pan(int32_t(x)));
1944 330 break;
1945 }
1946
1947 case e1t8SHOTS: //Fire Wizzrobe
1948
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1949 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1950 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1951
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1952 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1953 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1954
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1955 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1956 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1957
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1958 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1959 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1960
1961 [[fallthrough]];
1962 case e1t4SHOTS: //Stalfos 3
1963
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1964 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1965 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1966
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1967 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1968 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1969
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1970 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1971 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1972
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1973 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1974 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1975 1937 sfx(wpnsfx(wpn),pan(int32_t(x)));
1976 1937 break;
1977
1978 case e1tSUMMON: // Bat Wizzrobe
1979 {
1980 if(dmisc4==0) break; // Summon 0
1981
1982 int32_t bc=0;
1983
1984 for(int32_t gc=0; gc<guys.Count(); gc++)
1985 {
1986 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1987 {
1988 ++bc;
1989 }
1990 }
1991
1992 if(bc<=40) // Not too many enemies
1993 {
1994 int32_t kids = guys.Count();
1995 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1996
1997 for(int32_t i=0; i<bats; i++)
1998 {
1999 if(addchild(x,y,dmisc3,-10, this->script_UID))
2000 {
2001 ((enemy*)guys.spr(kids+i))->count_enemy = false;
2002
2003 }
2004 }
2005
2006 sfx(firesfx, pan(int32_t(x)));
2007 }
2008
2009 break;
2010 }
2011
2012 case e1tSUMMONLAYER: // Summoner
2013 {
2014 if(count_layer_enemies()==0)
2015 {
2016 break;
2017 }
2018
2019 int32_t kids = guys.Count();
2020
2021 if(kids<40)
2022 {
2023 int32_t newguys=(zc_oldrand()%3)+1;
2024 bool summoned=false;
2025
2026 for(int32_t i=0; i<newguys; i++)
2027 {
2028 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
2029 int32_t x2=0;
2030 int32_t y2=0;
2031
2032 for(int32_t k=0; k<20; ++k)
2033 {
2034 x2=16*((zc_oldrand()%12)+2);
2035 y2=16*((zc_oldrand()%7)+2);
2036
2037 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
2038 {
2039 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
2040 {
2041 ((enemy*)guys.spr(kids+i))->count_enemy = false;
2042 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
2043 {
2044 ((enemy*)guys.spr(kids+i))->fakez = 64;
2045 ((enemy*)guys.spr(kids+i))->z = 0;
2046 }
2047 }
2048
2049 summoned=true;
2050 break;
2051 }
2052 }
2053 }
2054
2055 if(summoned)
2056 {
2057 sfx(firesfx, pan(int32_t(x)));
2058 }
2059 }
2060
2061 break;
2062 }
2063 }
2064 44567 }
2065
2066
2067 // Hit the shield(s)?
2068 // Apparently, this function is only used for hookshots...
2069 2767 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2070 {
2071
6/6
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 1791 times.
✓ Branch 2 taken 975 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 141 times.
✓ Branch 5 taken 834 times.
2767 if(!(family==eeWALK || family==eeFIRE || family==eeOTHER))
2072 834 return false;
2073
2074 1933 bool ret = false;
2075
2076 // TODO: There must be some bitwise operations that can simplify this...
2077
9/12
✓ Branch 0 taken 1207 times.
✓ Branch 1 taken 726 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 683 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 699 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 699 times.
✓ Branch 10 taken 699 times.
✗ Branch 11 not taken.
1933 if(wpny > y) ret = ((flags&guy_shield_front && xdir==down) || (flags&guy_shield_back && xdir==up) || (flags&guy_shield_left && xdir==left) || (flags&guy_shield_right && xdir==right));
2078
9/12
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 824 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 778 times.
✓ Branch 4 taken 33 times.
✓ Branch 5 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 811 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 811 times.
✓ Branch 10 taken 811 times.
✗ Branch 11 not taken.
1207 else if(wpny < y) ret = ((flags&guy_shield_front && xdir==up) || (flags&guy_shield_back && xdir==down) || (flags&guy_shield_left && xdir==right) || (flags&guy_shield_right && xdir==left));
2079
2080
11/14
✓ Branch 0 taken 1065 times.
✓ Branch 1 taken 868 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 849 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 825 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 840 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 840 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 840 times.
1933 if(wpnx < x) ret = ret || ((flags&guy_shield_front && xdir==left) || (flags&guy_shield_back && xdir==right) || (flags&guy_shield_left && xdir==down) || (flags&guy_shield_right && xdir==up));
2081
11/14
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 863 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 827 times.
✓ Branch 6 taken 19 times.
✓ Branch 7 taken 17 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 844 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 844 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 844 times.
1065 else if(wpnx > x) ret = ret || ((flags&guy_shield_front && xdir==right) || (flags&guy_shield_back && xdir==left) || (flags&guy_shield_left && xdir==up) || (flags&guy_shield_right && xdir==down));
2082
2083 1933 return ret;
2084 2767 }
2085
2086
2087 //! Weapon Editor for 2.6
2088 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2089
2090
2091 //converts a wqeapon ID to its defence index.
2092 126851 int32_t weaponToDefence(int32_t wid)
2093 {
2094
23/47
✗ Branch 0 not taken.
✓ Branch 1 taken 64409 times.
✓ Branch 2 taken 9432 times.
✓ Branch 3 taken 25029 times.
✓ Branch 4 taken 4207 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3146 times.
✓ Branch 9 taken 9836 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 269 times.
✓ Branch 13 taken 1217 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 512 times.
✓ Branch 17 taken 1459 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2036 times.
✓ Branch 20 taken 2767 times.
✓ Branch 21 taken 610 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 240 times.
✓ Branch 24 taken 469 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 19 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 26 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 12 times.
✓ Branch 33 taken 77 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✓ Branch 39 taken 993 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 1 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
126851 switch(wid)
2095 {
2096 case wNone: return -1;
2097 64409 case wSword: return edefSWORD;
2098 9432 case wBeam: return edefBEAM;
2099 25029 case wBrang: return edefBRANG;
2100 4207 case wBomb: return edefBOMB;
2101 37 case wSBomb: return edefSBOMB;
2102 48 case wLitBomb: return edefBOMB;
2103 case wLitSBomb: return edefSBOMB;
2104 3146 case wArrow: return edefARROW;
2105 9836 case wFire: return edefFIRE;
2106 case wWhistle:
2107 {
2108 return edefWhistle;
2109 }
2110 case wBait: return edefBAIT;
2111 269 case wWand: return edefWAND;
2112 1217 case wMagic: return edefMAGIC;
2113 case wCatching: return -1;
2114 case wWind: return edefWIND;
2115 512 case wRefMagic: return edefREFMAGIC;
2116 1459 case wRefFireball: return edefREFBALL;
2117 case wRefRock: return edefREFROCK;
2118 2036 case wHammer: return edefHAMMER;
2119 2767 case wHookshot: return edefHOOKSHOT;
2120 610 case wHSHandle: return edefHOOKSHOT;
2121 case wHSChain: return edefHOOKSHOT;
2122 240 case wSSparkle: return edefSPARKLE;
2123 469 case wFSparkle: return edefSPARKLE;
2124 case wSmack: return -1; // is this the candle object?
2125 case wPhantom: return -1; //engine created visual effects.
2126 case wCByrna: return edefBYRNA;
2127 19 case wRefBeam: return edefREFBEAM;
2128 case wStomp: return edefSTOMP;
2129 26 case wScript1: return edefSCRIPT01;
2130 case wScript2: return edefSCRIPT02;
2131 12 case wScript3: return edefSCRIPT03;
2132 77 case wScript4: return edefSCRIPT04;
2133 case wScript5: return edefSCRIPT05;
2134 case wScript6: return edefSCRIPT06;
2135 case wScript7: return edefSCRIPT07;
2136 case wScript8: return edefSCRIPT08;
2137 case wScript9: return edefSCRIPT09;
2138 993 case wScript10: return edefSCRIPT10;
2139 case wIce: return edefICE;
2140 case wSound: return edefSONIC;
2141 1 case wThrown: return edefTHROWN;
2142 case wRefArrow: return edefREFARROW;
2143 case wRefFire: return edefREFFIRE;
2144 case wRefFire2: return edefREFFIRE2;
2145 //case wPot: return edefPOT;
2146 // case wLitZap: return edefELECTRIC;
2147 // case wZ3Sword: return edefZ3SWORD;
2148 // case wLASWord: return edefLASWORD;
2149 // case wSpinAttk: return edefSPINATTK;
2150 // case wShield: return edefSHIELD;
2151 // case wTrowel: return edefTROWEL;
2152
2153 default: return -1;
2154 }
2155 126851 }
2156
2157 126851 int32_t getDefType(weapon *w)
2158 {
2159 126851 int32_t id = getWeaponID(w);
2160 126851 int32_t edef = weaponToDefence(id);
2161
2/2
✓ Branch 0 taken 123474 times.
✓ Branch 1 taken 3377 times.
126851 if(edef == edefHOOKSHOT)
2162 {
2163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3377 times.
3377 if(w->family_class == itype_switchhook)
2164 return edefSwitchHook;
2165 3377 }
2166 126851 return edef;
2167 126851 }
2168
2169 225906 int32_t getWeaponID(weapon *w)
2170 {
2171 225906 int32_t usewpn = w->useweapon;
2172
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 225676 times.
225906 return (usewpn > 0) ? usewpn : w->id;
2173 }
2174
2175 126851 int32_t enemy::resolveEnemyDefence(weapon *w)
2176 {
2177 //sword edef is 9, but we're reading it at 0
2178 //,
2179 126851 int32_t weapondef = 0;
2180 126851 int32_t wdeftype = getDefType(w);
2181 126851 int32_t usedef = w->usedefence;
2182
2183
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 126851 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
126851 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2184 {
2185 weapondef = usedef*-1;
2186 }
2187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126851 times.
126851 else if(unsigned(wdeftype) < edefLAST255)
2188 {
2189 126851 weapondef = wdeftype;
2190 126851 }
2191 126851 return weapondef;
2192 }
2193
2194 137394 byte get_def_ignrflag(int32_t edef)
2195 {
2196
3/3
✓ Branch 0 taken 114464 times.
✓ Branch 1 taken 3668 times.
✓ Branch 2 taken 19262 times.
137394 switch(edef)
2197 {
2198 case edIGNORE:
2199 case edIGNOREL1:
2200 case edSTUNORIGNORE:
2201 19262 return WPNUNB_IGNR;
2202 case edSTUNORCHINK:
2203 case edCHINK:
2204 case edCHINKL1:
2205 case edCHINKL2:
2206 case edCHINKL4:
2207 case edCHINKL6:
2208 case edCHINKL8:
2209 case edCHINKL10:
2210 case edLEVELCHINK2:
2211 case edLEVELCHINK3:
2212 case edLEVELCHINK4:
2213 case edLEVELCHINK5:
2214 3668 return WPNUNB_BLOCK;
2215 }
2216 114464 return 0;
2217 137394 }
2218
2219 137394 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2220 {
2221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137394 times.
137394 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2222 switch(edef)
2223 {
2224 case edIGNORE:
2225 case edIGNOREL1:
2226 case edCHINK:
2227 case edCHINKL1:
2228 case edCHINKL2:
2229 case edCHINKL4:
2230 case edCHINKL6:
2231 case edCHINKL8:
2232 case edCHINKL10:
2233 case edLEVELCHINK2:
2234 case edLEVELCHINK3:
2235 case edLEVELCHINK4:
2236 case edLEVELCHINK5:
2237 return edNORMAL;
2238 case edSTUNORIGNORE:
2239 case edSTUNORCHINK:
2240 return edSTUNONLY;
2241 }
2242 return edef;
2243 137394 }
2244
2245 // Do we do damage?
2246 // 0: takehit returns 0
2247 // 1: takehit returns 1
2248 // -1: do damage
2249 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2250 125858 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2251 {
2252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125858 times.
125858 if(switch_hooked) return 0;
2253 125858 int32_t tempx = x;
2254 125858 int32_t tempy = y;
2255 125858 int32_t the_defence = 0;
2256
1/2
✓ Branch 0 taken 125858 times.
✗ Branch 1 not taken.
125858 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2257 {
2258 the_defence = edef*-1; //A specific defence type.
2259 }
2260 125858 else the_defence = defense[edef];
2261
2262 125858 the_defence = conv_edef_unblockable(the_defence, unblockable);
2263
2264
3/4
✓ Branch 0 taken 6573 times.
✓ Branch 1 taken 119285 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6573 times.
125858 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2265 {
2266
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6566 times.
✓ Branch 2 taken 7 times.
6573 switch(the_defence)
2267 {
2268 case edIGNORE:
2269 7 return 0;
2270 case edIGNOREL1:
2271 case edSTUNORIGNORE:
2272 if(*power <= 0)
2273 return 0;
2274 }
2275 6566 sfx(WAV_CHINK,pan(int32_t(x)));
2276 6566 return 1;
2277 }
2278
2279 119285 int32_t new_id = id;
2280 119285 int32_t effect_type = dmisc15;
2281 119285 int32_t delay_timer = 90;
2282 119285 enemy *gleeok = NULL;
2283 119285 enemy *ptra = NULL;
2284 119285 int32_t c = 0;
2285
2286
16/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 492 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1931 times.
✓ Branch 6 taken 1862 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 43 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 930 times.
✓ Branch 13 taken 17324 times.
✓ Branch 14 taken 883 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 2175 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 158 times.
✓ Branch 26 taken 105 times.
✓ Branch 27 taken 4 times.
✓ Branch 28 taken 93064 times.
119285 switch(the_defence)
2287 {
2288 case edREPLACE:
2289 {
2290 sclk = 0;
2291 if ( dmisc16 > 0 ) new_id = dmisc16;
2292 else new_id = id+1;
2293 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2294 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2295 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2296
2297 //Z_scripterrlog("new id is %d\n", new_id);
2298 switch(guysbuf[new_id&0xFFF].family)
2299 {
2300 //Fixme: possible enemy memory leak. (minor)
2301 case eeWALK:
2302 {
2303 enemy *e = new eStalfos(x,y,new_id,clk);
2304 guys.add(e);
2305 }
2306 break;
2307
2308 case eeLEV:
2309 {
2310 enemy *e = new eLeever(x,y,new_id,clk);
2311 guys.add(e);
2312 }
2313 break;
2314
2315 case eeTEK:
2316 {
2317 enemy *e = new eTektite(x,y,new_id,clk);
2318 guys.add(e);
2319 }
2320 break;
2321
2322 case eePEAHAT:
2323 {
2324 enemy *e = new ePeahat(x,y,new_id,clk);
2325 guys.add(e);
2326 }
2327 break;
2328
2329 case eeZORA:
2330 {
2331 enemy *e = new eZora(x,y,new_id,clk);
2332 guys.add(e);
2333 }
2334 break;
2335
2336 case eeGHINI:
2337 {
2338 enemy *e = new eGhini(x,y,new_id,clk);
2339 guys.add(e);
2340 }
2341 break;
2342
2343 case eeKEESE:
2344 {
2345 enemy *e = new eKeese(x,y,new_id,clk);
2346 guys.add(e);
2347 }
2348 break;
2349
2350 case eeWIZZ:
2351 {
2352 enemy *e = new eWizzrobe(x,y,new_id,clk);
2353 guys.add(e);
2354 }
2355 break;
2356
2357 case eePROJECTILE:
2358 {
2359 enemy *e = new eProjectile(x,y,new_id,clk);
2360 guys.add(e);
2361 }
2362 break;
2363
2364 case eeWALLM:
2365 {
2366 enemy *e = new eWallM(x,y,new_id,clk);
2367 guys.add(e);
2368 }
2369 break;
2370
2371 case eeAQUA:
2372 {
2373 enemy *e = new eAquamentus(x,y,new_id,clk);
2374 guys.add(e);
2375 e->x = x;
2376 e->y = y;
2377 }
2378 break;
2379
2380 case eeMOLD:
2381 {
2382 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0])));
2383 guys.add(e);
2384 e->x = x;
2385 e->y = y;
2386 }
2387 break;
2388
2389 case eeMANHAN:
2390 {
2391 enemy *e = new eManhandla(x,y,new_id,clk);
2392 guys.add(e);
2393 e->x = x;
2394 e->y = y;
2395 }
2396 break;
2397
2398 case eeGLEEOK:
2399 {
2400 *power = 0;
2401 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].attributes[0]);
2402 guys.add(gleeok);
2403 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2404 new_id &= 0xFFF;
2405 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2406 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2407 for(int32_t i=0; i<head_cnt; i++)
2408 {
2409 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2410 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2411 {
2412 al_trace("Gleeok head %d could not be created!\n",i+1);
2413
2414 for(int32_t j=0; j<i+1; j++)
2415 {
2416 guys.del(guys.Count()-1);
2417 }
2418
2419 break;
2420 }
2421 else
2422 {
2423 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2424 }
2425
2426 c-=guysbuf[new_id].attributes[3];
2427 //gleeok->x = x;
2428 //gleeok->y = y;
2429 //gleeok = e;
2430 }
2431 return 1;
2432 }
2433
2434 case eeGHOMA:
2435 {
2436 enemy *e = new eGohma(x,y,new_id,clk);
2437 guys.add(e);
2438 e->x = x;
2439 e->y = y;
2440 }
2441 break;
2442
2443 case eeLANM:
2444 {
2445 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])));
2446 guys.add(e);
2447 e->x = x;
2448 e->y = y;
2449 }
2450 break;
2451
2452 case eeGANON:
2453 {
2454 enemy *e = new eGanon(x,y,new_id,clk);
2455 guys.add(e);
2456 e->x = x;
2457 e->y = y;
2458 }
2459 break;
2460
2461 case eeFAIRY:
2462 {
2463 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2464 guys.add(e);
2465 e->x = x;
2466 e->y = y;
2467 }
2468 break;
2469
2470 case eeFIRE:
2471 {
2472 enemy *e = new eFire(x,y,new_id,clk);
2473 guys.add(e);
2474 e->x = x;
2475 e->y = y;
2476 }
2477 break;
2478
2479 case eeOTHER:
2480 {
2481 enemy *e = new eOther(x,y,new_id,clk);
2482 guys.add(e);
2483 e->x = x;
2484 e->y = y;
2485 }
2486 break;
2487
2488 case eeSPINTILE:
2489 {
2490 enemy *e = new eSpinTile(x,y,new_id,clk);
2491 guys.add(e);
2492 e->x = x;
2493 e->y = y;
2494 }
2495 break;
2496
2497 // and these enemies use the misc10/misc2 value
2498 case eeROCK:
2499 {
2500 switch(guysbuf[new_id&0xFFF].attributes[9])
2501 {
2502 case 1:
2503 {
2504 enemy *e = new eBoulder(x,y,new_id,clk);
2505 guys.add(e);
2506 e->x = x;
2507 e->y = y;
2508 }
2509 break;
2510
2511 case 0:
2512 default:
2513 {
2514 enemy *e = new eRock(x,y,new_id,clk);
2515 guys.add(e);
2516 e->x = x;
2517 e->y = y;
2518 }
2519 break;
2520 }
2521
2522 break;
2523 }
2524
2525 case eeTRAP:
2526 {
2527 switch(guysbuf[new_id&0xFFF].attributes[1])
2528 {
2529 case 1:
2530 {
2531 enemy *e = new eTrap2(x,y,new_id,clk);
2532 guys.add(e);
2533 e->x = x;
2534 e->y = y;
2535 }
2536 break;
2537
2538 case 0:
2539 default:
2540 {
2541 enemy *e = new eTrap(x,y,new_id,clk);
2542 guys.add(e);
2543 e->x = x;
2544 e->y = y;
2545 }
2546 break;
2547 }
2548
2549 break;
2550 }
2551
2552 case eeDONGO:
2553 {
2554 switch(guysbuf[new_id&0xFFF].attributes[9])
2555 {
2556 case 1:
2557 {
2558 enemy *e = new eDodongo2(x,y,new_id,clk);
2559 guys.add(e);
2560 e->x = x;
2561 e->y = y;
2562 }
2563 break;
2564
2565 case 0:
2566 default:
2567 {
2568 enemy *e = new eDodongo(x,y,new_id,clk);
2569 guys.add(e);
2570 e->x = x;
2571 e->y = y;
2572 }
2573 break;
2574 }
2575
2576 break;
2577 }
2578
2579 case eeDIG:
2580 {
2581 switch(guysbuf[new_id&0xFFF].attributes[9])
2582 {
2583 case 1:
2584 {
2585 enemy *e = new eLilDig(x,y,new_id,clk);
2586 guys.add(e);
2587 e->x = x;
2588 e->y = y;
2589 }
2590 break;
2591
2592 case 0:
2593 default:
2594 {
2595 enemy *e = new eBigDig(x,y,new_id,clk);
2596 guys.add(e);
2597 e->x = x;
2598 e->y = y;
2599 }
2600 break;
2601 }
2602
2603 break;
2604 }
2605
2606 case eePATRA:
2607 {
2608 switch(guysbuf[new_id&0xFFF].attributes[9])
2609 {
2610 case 1:
2611 {
2612 if (get_qr(qr_HARDCODED_BS_PATRA))
2613 {
2614 enemy *e = new ePatraBS(x,y,new_id,clk);
2615 guys.add(e);
2616 e->x = x;
2617 e->y = y;
2618 break;
2619 }
2620 }
2621 [[fallthrough]];
2622 case 0:
2623 default:
2624 {
2625 enemy *e = new ePatra(x,y,new_id,clk);
2626 guys.add(e);
2627 e->x = x;
2628 e->y = y;
2629 }
2630 break;
2631 }
2632
2633 break;
2634 }
2635
2636 case eeGUY:
2637 {
2638 switch(guysbuf[new_id&0xFFF].attributes[9])
2639 {
2640 case 1:
2641 {
2642 enemy *e = new eTrigger(x,y,new_id,clk);
2643 guys.add(e);
2644 }
2645 break;
2646
2647 case 0:
2648 default:
2649 {
2650 enemy *e = new eNPC(x,y,new_id,clk);
2651 guys.add(e);
2652 }
2653 break;
2654 }
2655
2656 break;
2657 }
2658
2659 case eeSCRIPT01:
2660 case eeSCRIPT02:
2661 case eeSCRIPT03:
2662 case eeSCRIPT04:
2663 case eeSCRIPT05:
2664 case eeSCRIPT06:
2665 case eeSCRIPT07:
2666 case eeSCRIPT08:
2667 case eeSCRIPT09:
2668 case eeSCRIPT10:
2669 case eeSCRIPT11:
2670 case eeSCRIPT12:
2671 case eeSCRIPT13:
2672 case eeSCRIPT14:
2673 case eeSCRIPT15:
2674 case eeSCRIPT16:
2675 case eeSCRIPT17:
2676 case eeSCRIPT18:
2677 case eeSCRIPT19:
2678 case eeSCRIPT20:
2679 {
2680 enemy *e = new eScript(x,y,new_id,clk);
2681 guys.add(e);
2682 e->x = x;
2683 e->y = y;
2684 break;
2685 }
2686
2687
2688 case eeFFRIENDLY01:
2689 case eeFFRIENDLY02:
2690 case eeFFRIENDLY03:
2691 case eeFFRIENDLY04:
2692 case eeFFRIENDLY05:
2693 case eeFFRIENDLY06:
2694 case eeFFRIENDLY07:
2695 case eeFFRIENDLY08:
2696 case eeFFRIENDLY09:
2697 case eeFFRIENDLY10:
2698 {
2699 enemy *e = new eFriendly(x,y,new_id,clk);
2700 guys.add(e);
2701 e->x = x;
2702 e->y = y;
2703 break;
2704 }
2705
2706
2707 default: break;
2708 }
2709
2710 // add segments of segmented enemies
2711 int32_t c=0;
2712
2713 switch(guysbuf[new_id&0xFFF].family)
2714 {
2715 case eeMOLD:
2716 {
2717 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2718 new_id &= 0xFFF;
2719
2720 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].attributes[0])); i++)
2721 {
2722 //christ this is messy -DD
2723 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2724
2725 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2726 {
2727 al_trace("Moldorm segment %d could not be created!\n",i+1);
2728
2729 for(int32_t j=0; j<i+1; j++)
2730 guys.del(guys.Count()-1);
2731
2732 return 0;
2733 }
2734
2735 if(i>0)
2736 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2737
2738
2739 }
2740
2741 break;
2742 }
2743
2744 case eeLANM:
2745 {
2746 new_id &= 0xFFF;
2747 int32_t shft = guysbuf[new_id].attributes[1];
2748 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2749 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2750
2751 if(!guys.add(e))
2752 {
2753 al_trace("Lanmola segment 1 could not be created!\n");
2754 guys.del(guys.Count()-1);
2755 return 0;
2756 }
2757 e->x = x;
2758 e->y = y;
2759
2760
2761
2762 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])); i++)
2763 {
2764 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2765 if(!guys.add(e2))
2766 {
2767 al_trace("Lanmola segment %d could not be created!\n",i+1);
2768
2769 for(int32_t j=0; j<i+1; j++)
2770 guys.del(guys.Count()-1);
2771
2772 return 0;
2773 }
2774 e2->x = x;
2775 e2->y = y;
2776
2777 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2778
2779 }
2780 }
2781 break;
2782
2783 case eeMANHAN:
2784 new_id &= 0xFFF;
2785
2786 for(int32_t i=0; i<((!(guysbuf[new_id].attributes[1]))?4:8); i++)
2787 {
2788 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2789 {
2790 al_trace("Manhandla head %d could not be created!\n",i+1);
2791
2792 for(int32_t j=0; j<i+1; j++)
2793 {
2794 guys.del(guys.Count()-1);
2795 }
2796
2797 return 0;
2798 }
2799
2800
2801 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].attributes[0];
2802 }
2803
2804 break;
2805
2806 case eeGLEEOK:
2807 {
2808 /*
2809 new_id &= 0xFFF;
2810 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2811 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2812 for(int32_t i=0; i<head_cnt; i++)
2813 {
2814 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2815 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2816 {
2817 al_trace("Gleeok head %d could not be created!\n",i+1);
2818
2819 for(int32_t j=0; j<i+1; j++)
2820 {
2821 guys.del(guys.Count()-1);
2822 }
2823
2824 break;
2825 }
2826
2827 c-=guysbuf[new_id].misc4;
2828 */
2829
2830 // }
2831 }
2832 break;
2833
2834
2835 case eePATRA:
2836 {
2837 new_id &= 0xFFF;
2838 int32_t outeyes = 0;
2839 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2840
2841 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[0]); i++)
2842 {
2843 if(!((guysbuf[new_id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2844 {
2845 al_trace("Patra outer eye %d could not be created!\n",i+1);
2846
2847 for(int32_t j=0; j<i+1; j++)
2848 guys.del(guys.Count()-1);
2849
2850 return 0;
2851 }
2852 else
2853 outeyes++;
2854
2855
2856 }
2857
2858 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[1]); i++)
2859 {
2860 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2861 {
2862 al_trace("Patra inner eye %d could not be created!\n",i+1);
2863
2864 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2865 guys.del(guys.Count()-1);
2866
2867 return 0;
2868 }
2869
2870
2871 }
2872 delete ptra;
2873 break;
2874 }
2875 }
2876
2877
2878
2879 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2880 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2881 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2882 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2883 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2884 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2885 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2886 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2887 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2888 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2889 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2890 ((enemy*)guys.spr(guys.Count()-1))->script_UID = this->script_UID;
2891 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2892
2893
2894 item_set = 0; //Do not make a drop.
2895
2896 switch(effect_type)
2897 {
2898 case -7:
2899 {
2900 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2901 Lwpns.add(w);
2902 break;
2903 }
2904 case -6:
2905 {
2906 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2907 Lwpns.add(w);
2908 break;
2909 }
2910 case -5:
2911 {
2912 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2913 Lwpns.add(w);
2914 break;
2915 }
2916 case -4:
2917 {
2918 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2919 Lwpns.add(w);
2920 break;
2921 }
2922 case -3: explode(1); break;
2923 case -2: explode(2); break;
2924 case -1: explode(0); break;
2925 case 0: break;
2926
2927 default:
2928 {
2929 //Dummy weapon function
2930 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2931 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2932 Lwpns.add(w);
2933 break;
2934 }
2935 }
2936
2937
2938 yofs = -32768;
2939 switch(guysbuf[new_id&0xFFF].family)
2940 {
2941 case eeGLEEOK:
2942 {
2943 Z_scripterrlog("Replacing a gleeok.\n");
2944 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2945 hp = -999;
2946 tempenemy->hp = -999;
2947 break;
2948
2949 }
2950 default:
2951 hp = -1000; break;
2952 }
2953 ++game->guys[(currmap*MAPSCRSNORMAL)+currscr];
2954 return 1;
2955
2956 }
2957 case edSPLIT:
2958 {
2959 for ( int32_t q = 0; q < dmisc4; q++ )
2960 {
2961 addenemy(
2962 //ex,ey,
2963 x,y,
2964 dmisc3+0x1000,-15);
2965
2966 }
2967 item_set = 0; //Do not make a drop.
2968 hp = -1000;
2969 return -1;
2970
2971 }
2972 case edSUMMON:
2973 {
2974 int32_t summon_count = (zc_oldrand()%dmisc4)+1;
2975 for ( int32_t q = 0; q < summon_count; q++ )
2976 {
2977 int32_t x2=16*((zc_oldrand()%12)+2);
2978 int32_t y2=16*((zc_oldrand()%7)+2);
2979 addenemy(
2980 x2,y2,
2981 dmisc3+0x1000,-15);
2982
2983 }
2984 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2985 return -1;
2986
2987 }
2988
2989 case edEXPLODESMALL:
2990 {
2991 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2992 Ewpns.add(ew);
2993 item_set = 0; //Should we make a drop?
2994 hp = -1000;
2995 return -1;
2996 }
2997
2998
2999 case edEXPLODEHARMLESS:
3000 {
3001 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
3002 Ewpns.add(ew);
3003 ew->hyofs = -32768;
3004 item_set = 0; //Should we make a drop?
3005 hp = -1000;
3006 return -1;
3007 }
3008
3009
3010 case edEXPLODELARGE:
3011 {
3012 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
3013 Ewpns.add(ew);
3014
3015 hp = -1000;
3016 return -1;
3017 }
3018
3019
3020 case edTRIGGERSECRETS:
3021 {
3022 hidden_entrance(0, true, false, -4);
3023 return -1;
3024 }
3025
3026 case edSTUNORCHINK:
3027
3/4
✓ Branch 0 taken 1119 times.
✓ Branch 1 taken 1056 times.
✓ Branch 2 taken 1119 times.
✗ Branch 3 not taken.
3701 if (stunclk && get_qr(qr_NO_STUNLOCK))
3028 {
3029 sfx(WAV_CHINK,pan(int32_t(x)));
3030 return 1;
3031 }
3032
2/2
✓ Branch 0 taken 649 times.
✓ Branch 1 taken 1526 times.
2175 else if(*power <= 0)
3033 {
3034 649 sfx(WAV_CHINK,pan(int32_t(x)));
3035 649 return 1;
3036 }
3037 [[fallthrough]];
3038
3039 case edSTUNORIGNORE:
3040
3/4
✓ Branch 0 taken 1952 times.
✓ Branch 1 taken 1505 times.
✓ Branch 2 taken 1952 times.
✗ Branch 3 not taken.
5959 if (stunclk && get_qr(qr_NO_STUNLOCK))
3041 {
3042 sfx(WAV_CHINK,pan(int32_t(x)));
3043 return 1;
3044 }
3045
2/2
✓ Branch 0 taken 955 times.
✓ Branch 1 taken 2502 times.
3457 else if(*power <= 0)
3046 955 return 0;
3047 [[fallthrough]];
3048
3049 case edSTUNONLY:
3050
7/10
✓ Branch 0 taken 4364 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4364 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4364 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3817 times.
✓ Branch 7 taken 547 times.
✓ Branch 8 taken 4043 times.
✓ Branch 9 taken 321 times.
4364 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3051 {
3052 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3053 321 return 1;
3054 }
3055
3/4
✓ Branch 0 taken 3118 times.
✓ Branch 1 taken 925 times.
✓ Branch 2 taken 3118 times.
✗ Branch 3 not taken.
4043 if (stunclk && get_qr(qr_NO_STUNLOCK))
3056 {
3057 sfx(WAV_CHINK,pan(int32_t(x)));
3058 return 1;
3059 }
3060 else
3061 {
3062 4043 stunclk=160;
3063 4043 sfx(WAV_EHIT,pan(int32_t(x)));
3064
3065 4043 return 1;
3066 }
3067
3068 case edCHINKL1:
3069 if(*power >= 1*game->get_hero_dmgmult()) break;
3070 [[fallthrough]];
3071 case edCHINKL2:
3072
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 61 times.
113 if(*power >= 2*game->get_hero_dmgmult()) break;
3073 [[fallthrough]];
3074 case edCHINKL4:
3075
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 110 times.
190 if(*power >= 4*game->get_hero_dmgmult()) break;
3076 [[fallthrough]];
3077 case edCHINKL6:
3078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 6*game->get_hero_dmgmult()) break;
3079 [[fallthrough]];
3080 case edCHINKL8:
3081
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 111 times.
154 if(*power >= 8*game->get_hero_dmgmult()) break;
3082 [[fallthrough]];
3083 case edCHINKL10:
3084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 10*game->get_hero_dmgmult()) break;
3085 [[fallthrough]];
3086 case edCHINK:
3087 1041 sfx(WAV_CHINK,pan(int32_t(x)));
3088 1041 return 1;
3089
3090 case edIGNOREL1:
3091 if(*power > 0) break;
3092 [[fallthrough]];
3093
3094 case edIGNORE:
3095 17324 return 0;
3096
3097 case ed1HKO:
3098 492 *power = hp;
3099 492 return -2;
3100
3101 case ed2x:
3102 {
3103
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 *power = zc_max(1,*power*2);
3104 //int32_t pow = *power;
3105 //*power = vbound((pow*2),0,214747);
3106 71 return -1;
3107 }
3108 case ed3x:
3109 {
3110 *power = zc_max(1,*power*3);
3111 //int32_t pow = *power;
3112 //*power = vbound((pow*3),0,214747);
3113 return -1;
3114 }
3115
3116 case ed4x:
3117 {
3118 *power = zc_max(1,*power*4);
3119 //int32_t pow = *power;
3120 //*power = vbound((pow*4),0,214747);
3121 return -1;
3122 }
3123
3124
3125 case edHEAL:
3126 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3127 //int32_t pow = *power;
3128 //*power = vbound((pow*-1),0,214747);
3129 //break;
3130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 *power = zc_min(0,*power*-1);
3131 158 return -1;
3132 }
3133 /*
3134 case edLEVELDAMAGE:
3135 {
3136 int32_t pow = *power;
3137 int32_t lvl = *level;
3138 *power = vbound((pow*lvl),0,214747);
3139 break;
3140 }
3141 case edLEVELREDUCTION:
3142 {
3143 int32_t pow = *power;
3144 int32_t lvl = *level;
3145 *power = vbound((pow/lvl),0,214747);
3146 break;
3147 }
3148 */
3149
3150 case edQUARTDAMAGE:
3151
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 3 times.
105 *power = zc_max(1,*power/2);
3152
3153 [[fallthrough]];
3154 case edHALFDAMAGE:
3155
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 156 times.
988 *power = zc_max(1,*power/2);
3156 988 break;
3157
3158 case edSWITCH:
3159 {
3160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(Hero.switchhookclk) return 0; //Already switching!
3161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 switch(family)
3162 {
3163 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3164 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3165 return 0;
3166 }
3167 4 hooked_combopos = -1;
3168 4 hooked_layerbits = 0;
3169 4 switching_object = this;
3170 4 switch_hooked = true;
3171 4 Hero.doSwitchHook(game->get_switchhookstyle());
3172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(QMisc.miscsfx[sfxSWITCHED])
3173 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
3174 4 return 1;
3175 }
3176
3177 case 0:
3178 {
3179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93064 times.
93064 if(edef == edefSwitchHook)
3180 return -1;
3181
6/6
✓ Branch 0 taken 19532 times.
✓ Branch 1 taken 73532 times.
✓ Branch 2 taken 58 times.
✓ Branch 3 taken 19474 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 26 times.
93064 if (stunclk && get_qr(qr_NO_STUNLOCK) && *power == 0)
3182 {
3183 26 sfx(WAV_CHINK,pan(int32_t(x)));
3184 26 return 1;
3185 }
3186
3187 }
3188 93038 }
3189
3190 94201 return -1;
3191 125858 }
3192
3193 125858 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3194 {
3195
1/2
✓ Branch 0 taken 125858 times.
✗ Branch 1 not taken.
125858 int wuid = w?w->getUID():0;
3196
1/2
✓ Branch 0 taken 125858 times.
✗ Branch 1 not taken.
125858 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3197
3198
1/2
✓ Branch 0 taken 125858 times.
✗ Branch 1 not taken.
125858 if(fakeweap)
3199 Lwpns.add(w);
3200 125858 std::vector<int32_t> &ev = FFCore.eventData;
3201 125858 ev.clear();
3202 125858 ev.push_back(*power*10000);
3203 125858 ev.push_back(edef*10000);
3204 125858 ev.push_back(unblockable*10000);
3205 125858 ev.push_back(wpnId*10000);
3206 125858 ev.push_back(0);
3207 125858 ev.push_back(getUID());
3208 125858 ev.push_back(wuid);
3209
3210 125858 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3211 125858 *power = ev[0]/10000;
3212 125858 edef = ev[1]/10000;
3213 125858 unblockable = byte(ev[2]/10000);
3214 125858 wpnId = ev[3] / 10000;
3215 125858 bool nullify = ev[4]!=0;
3216 125858 ev.clear();
3217 125858 int ret = 0;
3218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125858 times.
125858 if(!nullify)
3219 {
3220 125858 ret = defendNew(wpnId, power, edef, unblockable);
3221
2/2
✓ Branch 0 taken 32790 times.
✓ Branch 1 taken 93068 times.
125858 if(ret == -1)
3222 {
3223 93068 ev.push_back(*power*10000);
3224 93068 ev.push_back(edef*10000);
3225 93068 ev.push_back(unblockable*10000);
3226 93068 ev.push_back(wpnId*10000);
3227 93068 ev.push_back(0);
3228 93068 ev.push_back(getUID());
3229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93068 times.
93068 ev.push_back(w?w->getUID():0);
3230
3231 93068 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3232 93068 *power = ev[0]/10000;
3233 93068 nullify = ev[4]!=0;
3234 93068 ev.clear();
3235 93068 }
3236 125858 }
3237
1/2
✓ Branch 0 taken 125858 times.
✗ Branch 1 not taken.
125858 if(fakeweap)
3238 Lwpns.remove(w);
3239
3240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125858 times.
125858 return nullify ? 0 : ret;
3241 }
3242
3243 99055 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3244 {
3245
2/2
✓ Branch 0 taken 98478 times.
✓ Branch 1 taken 577 times.
99055 if(!realweap) realweap = w;
3246 99055 int32_t wid = getWeaponID(w);
3247
3248 99055 int32_t edef = resolveEnemyDefence(w);
3249
2/2
✓ Branch 0 taken 5832 times.
✓ Branch 1 taken 93223 times.
99055 if(QHeader.zelda_version > 0x250)
3250 5832 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3251
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 92230 times.
✗ Branch 2 not taken.
93223 switch(wid)
3252 {
3253 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3254 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3255 993 return defend(wpnId, power, edefSCRIPT);
3256
3257 case wWhistle:
3258 return -1;
3259
3260 default:
3261 92230 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3262 }
3263 99055 }
3264
3265
3266 // Check defenses without actually acting on them.
3267 27402 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3268 {
3269
4/10
✓ Branch 0 taken 15409 times.
✓ Branch 1 taken 11050 times.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
27402 switch(defense[edef])
3270 {
3271 case edSTUNONLY:
3272 474 return false;
3273 case edSTUNORCHINK:
3274 case edCHINK:
3275 15409 return unblockable&WPNUNB_BLOCK;
3276 case edSTUNORIGNORE:
3277 case edIGNORE:
3278 11050 return unblockable&WPNUNB_IGNR;
3279
3280 case edIGNOREL1:
3281 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3282 case edCHINKL1:
3283 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3284
3285 case edCHINKL2:
3286 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3287
3288 case edCHINKL4:
3289 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3290
3291 case edCHINKL6:
3292 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3293
3294 case edCHINKL8:
3295 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3296 }
3297
3298 469 return true;
3299 27402 }
3300
3301 // Do we do damage?
3302 // 0: takehit returns 0
3303 // 1: takehit returns 1
3304 // -1: do damage
3305 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3306 {
3307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3308 {
3309 switch(defense[edef])
3310 {
3311 case edIGNORE:
3312 return 0;
3313 case edIGNOREL1:
3314 case edSTUNORIGNORE:
3315 if(*power <= 0)
3316 return 0;
3317 }
3318
3319 sfx(WAV_CHINK,pan(int32_t(x)));
3320 return 1;
3321 }
3322
3323
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3324 {
3325 case edSTUNORCHINK:
3326 if(*power <= 0)
3327 {
3328 sfx(WAV_CHINK,pan(int32_t(x)));
3329 return 1;
3330 }
3331
3332 [[fallthrough]];
3333 case edSTUNORIGNORE:
3334 if(*power <= 0)
3335 return 0;
3336
3337 [[fallthrough]];
3338 case edSTUNONLY:
3339 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3340 return 1;
3341
3342 stunclk=160;
3343 sfx(WAV_EHIT,pan(int32_t(x)));
3344 return 1;
3345
3346 case edFREEZE:
3347 frozenclock=-1;
3348 //sfx(WAV_FREEZE,pan(int32_t(x)));
3349 return 1;
3350
3351 case edCHINKL1:
3352 if(*power >= 1*game->get_hero_dmgmult()) break;
3353 [[fallthrough]];
3354 case edCHINKL2:
3355 if(*power >= 2*game->get_hero_dmgmult()) break;
3356 [[fallthrough]];
3357 case edCHINKL4:
3358 if(*power >= 4*game->get_hero_dmgmult()) break;
3359 [[fallthrough]];
3360 case edCHINKL6:
3361 if(*power >= 6*game->get_hero_dmgmult()) break;
3362 [[fallthrough]];
3363 case edCHINKL8:
3364 if(*power >= 8*game->get_hero_dmgmult()) break;
3365 [[fallthrough]];
3366 case edCHINKL10:
3367 if(*power >= 10*game->get_hero_dmgmult()) break;
3368 [[fallthrough]];
3369 case edCHINK:
3370 sfx(WAV_CHINK,pan(int32_t(x)));
3371 return 1;
3372 case edTRIGGERSECRETS:
3373 hidden_entrance(0, true, false, -4);
3374 break;
3375
3376 case edIGNOREL1:
3377 if(*power > 0) break;
3378 [[fallthrough]];
3379 case edIGNORE:
3380 800 return 0;
3381
3382 case ed1HKO:
3383 *power = hp;
3384 return -2;
3385
3386 case ed2x:
3387 {
3388 *power = zc_max(1,*power*2);
3389 //int32_t pow = *power;
3390 //*power = vbound((pow*2),0,214747);
3391 return -1;
3392 }
3393 case ed3x:
3394 {
3395 *power = zc_max(1,*power*3);
3396 //int32_t pow = *power;
3397 //*power = vbound((pow*3),0,214747);
3398 return -1;
3399 }
3400
3401 case ed4x:
3402 {
3403 *power = zc_max(1,*power*4);
3404 //int32_t pow = *power;
3405 //*power = vbound((pow*4),0,214747);
3406 return -1;
3407 }
3408
3409
3410 case edHEAL:
3411 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3412 //int32_t pow = *power;
3413 //*power = vbound((pow*-1),0,214747);
3414 //break;
3415 *power = zc_min(0,*power*-1);
3416 return -1;
3417 }
3418 /*
3419 case edLEVELDAMAGE:
3420 {
3421 int32_t pow = *power;
3422 int32_t lvl = *level;
3423 *power = vbound((pow*lvl),0,214747);
3424 break;
3425 }
3426 case edLEVELREDUCTION:
3427 {
3428 int32_t pow = *power;
3429 int32_t lvl = *level;
3430 *power = vbound((pow/lvl),0,214747);
3431 break;
3432 }
3433 */
3434
3435
3436 case edQUARTDAMAGE:
3437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3438
3439 [[fallthrough]];
3440 case edHALFDAMAGE:
3441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3442 7 break;
3443 }
3444
3445 193 return -1;
3446 993 }
3447
3448 // Defend against a particular item class.
3449 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3450 {
3451 int32_t def=-1;
3452
3453 switch(wpnId)
3454 {
3455 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3456 case wBrang:
3457 def = defend(wpnId, power, edefBRANG);
3458 break;
3459
3460 case wHookshot:
3461 def = defend(wpnId, power, edefHOOKSHOT);
3462 break;
3463
3464 // Anyway...
3465 case wBomb:
3466 def = defend(wpnId, power, edefBOMB);
3467 break;
3468
3469 case wSBomb:
3470 def = defend(wpnId, power, edefSBOMB);
3471 break;
3472
3473 case wArrow:
3474 def = defend(wpnId, power, edefARROW);
3475 break;
3476
3477 case wFire:
3478 def = defend(wpnId, power, edefFIRE);
3479 break;
3480
3481 case wWand:
3482 def = defend(wpnId, power, edefWAND);
3483 break;
3484
3485 case wMagic:
3486 def = defend(wpnId, power, edefMAGIC);
3487 break;
3488
3489 case wHammer:
3490 def = defend(wpnId, power, edefHAMMER);
3491 break;
3492
3493 case wSword:
3494 def = defend(wpnId, power, edefSWORD);
3495 break;
3496
3497 case wBeam:
3498 def = defend(wpnId, power, edefBEAM);
3499 break;
3500
3501 case wRefBeam:
3502 def = defend(wpnId, power, edefREFBEAM);
3503 break;
3504
3505 case wRefMagic:
3506 def = defend(wpnId, power, edefREFMAGIC);
3507 break;
3508
3509 case wRefFireball:
3510 def = defend(wpnId, power, edefREFBALL);
3511 break;
3512
3513 case wRefRock:
3514 def = defend(wpnId, power, edefREFROCK);
3515 break;
3516
3517 case wStomp:
3518 def = defend(wpnId, power, edefSTOMP);
3519 break;
3520
3521 case wCByrna:
3522 def = defend(wpnId, power, edefBYRNA);
3523 break;
3524
3525 case wScript1:
3526 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3527 else def = defend(wpnId, power, edefSCRIPT);
3528 break;
3529
3530 case wScript2:
3531 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3532 else def = defend(wpnId, power, edefSCRIPT);
3533 break;
3534
3535 case wScript3:
3536 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3537 else def = defend(wpnId, power, edefSCRIPT);
3538 break;
3539
3540 case wScript4:
3541 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3542 else def = defend(wpnId, power, edefSCRIPT);
3543 break;
3544
3545 case wScript5:
3546 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3547 else def = defend(wpnId, power, edefSCRIPT);
3548 break;
3549
3550 case wScript6:
3551 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3552 else def = defend(wpnId, power, edefSCRIPT);
3553 break;
3554
3555 case wScript7:
3556 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3557 else def = defend(wpnId, power, edefSCRIPT);
3558 break;
3559
3560 case wScript8:
3561 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3562 else def = defend(wpnId, power, edefSCRIPT);
3563 break;
3564
3565 case wScript9:
3566 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3567 else def = defend(wpnId, power, edefSCRIPT);
3568 break;
3569
3570 case wScript10:
3571 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3572 else def = defend(wpnId, power, edefSCRIPT);
3573 break;
3574
3575 case wWhistle:
3576 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3577 else break;
3578 break;
3579
3580 case wRefArrow:
3581 def = defend(wpnId, power, edefREFARROW);
3582 break;
3583 case wRefFire:
3584 def = defend(wpnId, power, edefREFFIRE);
3585 break;
3586 case wRefFire2:
3587 def = defend(wpnId, power, edefREFFIRE2);
3588 break;
3589
3590 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3591 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3592 //of the ten if the quest version is lower than N.
3593 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3594 //such as bool UseSeparatedScriptDefences. hah.
3595 default:
3596 //if(wpnId>=wScript1 && wpnId<=wScript10)
3597 // {
3598 // def = defend(wpnId, power, edefSCRIPT);
3599 // }
3600 // }
3601
3602 break;
3603 }
3604
3605 return def;
3606 }
3607
3608 // take damage or ignore it
3609 // -1: damage (if any) dealt
3610 // 1: blocked
3611 // 0: weapon passes through unhindered
3612 264467 int32_t enemy::takehit(weapon *w, weapon* realweap)
3613 {
3614
2/4
✓ Branch 0 taken 264467 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 264467 times.
264467 if(fallclk||drownclk) return 0;
3615
2/2
✓ Branch 0 taken 69393 times.
✓ Branch 1 taken 195074 times.
264467 if(!realweap) realweap = w;
3616 264467 int32_t wpnId = w->id;
3617 264467 int32_t power = w->power;
3618 264467 int32_t wpnx = w->x;
3619 264467 int32_t wpny = w->y;
3620 264467 int32_t enemyHitWeapon = w->parentitem;
3621 int32_t wpnDir;
3622 264467 int32_t parent_item = w->parentitem;
3623
3624
2/2
✓ Branch 0 taken 264352 times.
✓ Branch 1 taken 115 times.
264467 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3625 {
3626 115 wpnId = w->useweapon;
3627 115 }
3628
3629 // If it's a boomerang that just bounced, use the opposite direction;
3630 // otherwise, it might bypass a shield. This probably won't handle
3631 // every case correctly, but it's better than having shields simply
3632 // not work against boomerangs.
3633
8/8
✓ Branch 0 taken 25075 times.
✓ Branch 1 taken 239392 times.
✓ Branch 2 taken 15580 times.
✓ Branch 3 taken 9495 times.
✓ Branch 4 taken 14362 times.
✓ Branch 5 taken 1218 times.
✓ Branch 6 taken 3306 times.
✓ Branch 7 taken 11056 times.
264467 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3634 11056 wpnDir = oppositeDir[w->dir];
3635 else
3636 253411 wpnDir = w->dir;
3637
3638
5/8
✓ Branch 0 taken 264467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 264467 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 264467 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8172 times.
✓ Branch 7 taken 271925 times.
264467 if(dying || clk<0 || hclk>0 || superman)
3639 8172 return 0;
3640
3641 //Prevent boomerang from writing to hitby[] for more than one frame.
3642 //This also prevents stunlock.
3643 //if ( stunclk > 0 ) return 0;
3644 //this needs a rule for boomerangs that cannot stunlock!
3645 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3646 //sigh.
3647
3648 271925 int32_t ret = -1;
3649
3650 // This obscure quest rule...
3651
5/6
✓ Branch 0 taken 91703 times.
✓ Branch 1 taken 180222 times.
✓ Branch 2 taken 88200 times.
✓ Branch 3 taken 3503 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 88200 times.
271925 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3652 {
3653 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3654 3503 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3655 3503 wpnDir=zc_oldrand()&3;
3656
3657
4/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 3036 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 189 times.
3503 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3658 {
3659 189 wpnDir=down;
3660 189 }
3661
4/4
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 2751 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 285 times.
3314 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3662 {
3663 285 wpnDir=right;
3664 285 }
3665
4/4
✓ Branch 0 taken 2342 times.
✓ Branch 1 taken 687 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 2064 times.
3029 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3666 {
3667 2064 wpnDir=up;
3668 2064 }
3669 else
3670 {
3671 965 wpnDir=left;
3672 }
3673 3503 }
3674
3675 271925 int32_t xdir = dir;
3676 271925 shieldCanBlock=false;
3677
3678
4/4
✓ Branch 0 taken 260645 times.
✓ Branch 1 taken 11280 times.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 257878 times.
272653 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3679
6/6
✓ Branch 0 taken 18250 times.
✓ Branch 1 taken 15483 times.
✓ Branch 2 taken 26192 times.
✓ Branch 3 taken 247169 times.
✓ Branch 4 taken 58 times.
✓ Branch 5 taken 247111 times.
260645 || ((flags&guy_shield_front && wpnDir==(xdir^down)) || (flags&guy_shield_back && wpnDir==(xdir^up)) ||
3680
4/4
✓ Branch 0 taken 984 times.
✓ Branch 1 taken 246127 times.
✓ Branch 2 taken 728 times.
✓ Branch 3 taken 245399 times.
247111 (flags&guy_shield_left && wpnDir==(xdir^(xdir&2?right:left))) || (flags&guy_shield_right && wpnDir==(xdir^(dir&2?left:right)))))
3681 )
3682 // The hammer should already be dealt with by subclasses (Walker etc.)
3683 {
3684
10/10
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 380 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 680 times.
✓ Branch 4 taken 5756 times.
✓ Branch 5 taken 338 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 153 times.
✓ Branch 9 taken 1488 times.
46212 switch(wpnId)
3685 {
3686 // Weapons which shields protect against
3687 case wSword:
3688 case wWand:
3689
2/2
✓ Branch 0 taken 5754 times.
✓ Branch 1 taken 2 times.
5758 if(Hero.getCharging()>0)
3690 2 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3691
3692 [[fallthrough]];
3693 case wHookshot:
3694 case wHSHandle:
3695 case wBrang:
3696 6136 shieldCanBlock=true;
3697 6474 break;
3698
3699 case wBeam:
3700 case wRefBeam:
3701 // Mirror shielded enemies!
3702 #if 0
3703 if(false /*flags&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3704 {
3705 if(wpnId>wEnemyWeapons)
3706 return 0;
3707
3708 sfx(WAV_CHINK,pan(int32_t(x)));
3709 return 1;
3710 }
3711
3712 #endif
3713
3714 [[fallthrough]];
3715 case wRefRock:
3716 case wRefFireball:
3717 case wMagic:
3718 #if 0
3719 if(false /*flags&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3720 {
3721 sfx(WAV_CHINK,pan(int32_t(x)));
3722 return 3;
3723 }
3724
3725 #endif
3726
3727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367 times.
367 if(wpnId>wEnemyWeapons)
3728 return 0;
3729
3730 [[fallthrough]];
3731 case wArrow:
3732 380 case wRefArrow:
3733 default:
3734 1868 shieldCanBlock=true;
3735 1868 break;
3736
3737 // Bombs
3738 case wSBomb:
3739 case wBomb:
3740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3741 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3742 {
3743 sfx(WAV_CHINK,pan(int32_t(x)));
3744 return 0;
3745 }
3746 else break;
3747
3748 // Weapons which ignore shields
3749 case wWhistle:
3750 case wHammer:
3751 153 break;
3752
3753 // Weapons which shouldn't be removed by shields
3754 case wLitBomb:
3755 case wLitSBomb:
3756 case wWind:
3757 case wPhantom:
3758 case wSSparkle:
3759 case wBait:
3760 864 return 0;
3761
3762 case wFire:
3763 case wRefFire:
3764 case wRefFire2:
3765 ;
3766 680 }
3767 8837 }
3768
3769
8/8
✓ Branch 0 taken 103171 times.
✓ Branch 1 taken 97398 times.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 27402 times.
✓ Branch 5 taken 25029 times.
✓ Branch 6 taken 2767 times.
✓ Branch 7 taken 9056 times.
265516 switch(wpnId)
3770 {
3771 case wWhistle: //No longer completely ignore whistle weapons! -Z
3772 {
3773
3774
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
423 if ( ((itemsbuf[parent_item].flags & item_flag2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3775 {
3776 423 return 0; break;
3777 }
3778 else
3779 {
3780 w->power = power = itemsbuf[parent_item].misc5;
3781
3782 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3783
3784 if(def <= 0)
3785 {
3786 if ( def == -2 ) hp -= hp;
3787 else hp -= power;
3788 return def;
3789 }
3790 break;
3791 }
3792 break;
3793 }
3794
3795 case wPhantom:
3796 270 return 0;
3797
3798 case wLitBomb:
3799 case wLitSBomb:
3800 case wBait:
3801 case wWind:
3802 case wSSparkle:
3803 103171 return 0;
3804
3805 case wFSparkle:
3806
3807 // Only take sparkle damage if the sparkle's parent item is not
3808 // defended against.
3809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27402 times.
27402 if(enemyHitWeapon > -1)
3810 {
3811 27402 int32_t p = 0;
3812 27402 int32_t f = itemsbuf[enemyHitWeapon].family;
3813
3814
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27402 times.
27402 switch(f)
3815 {
3816 case itype_arrow:
3817 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3818
3819 break;
3820
3821 case itype_cbyrna:
3822 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3823
3824 break;
3825
3826 case itype_brang:
3827
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 26933 times.
27402 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3828
3829 469 break;
3830
3831 default:
3832 return 0;
3833 }
3834 469 }
3835
3836 469 wpnId = wSword;
3837 469 power = game->get_hero_dmgmult()>>1;
3838 469 goto fsparkle;
3839 break;
3840
3841 case wBrang:
3842 {
3843 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3844 25029 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3845 //preventing stunlock might be best, here. -Z
3846
2/2
✓ Branch 0 taken 5471 times.
✓ Branch 1 taken 19558 times.
25029 if(def >= 0) return def;
3847
3848 // Not hurt by 0-damage weapons
3849
2/2
✓ Branch 0 taken 3184 times.
✓ Branch 1 taken 16374 times.
19558 if(!(flags & guy_bhit))
3850 {
3851 16374 stunclk=160;
3852
3853
3/4
✓ Branch 0 taken 16374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1305 times.
✓ Branch 3 taken 15069 times.
16374 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3854 {
3855
1/2
✓ Branch 0 taken 1305 times.
✗ Branch 1 not taken.
1305 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3856 1305 goto hitclock;
3857 }
3858
3859 15069 break;
3860 }
3861
3862
2/2
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 2793 times.
3184 if(!power)
3863
1/2
✓ Branch 0 taken 2793 times.
✗ Branch 1 not taken.
2793 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult();
3864 else
3865 391 hp-=power;
3866
3867 3184 goto hitclock;
3868 }
3869
3870 case wHookshot:
3871 {
3872 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3873 2767 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3874
3875
2/2
✓ Branch 0 taken 994 times.
✓ Branch 1 taken 1773 times.
2767 if(def >= 0) return def;
3876
3877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1773 times.
1773 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3878
3/4
✓ Branch 0 taken 1773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625 times.
✓ Branch 3 taken 148 times.
1773 if(swgrab || !(flags & guy_bhit))
3879 {
3880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1625 times.
1625 if(!swgrab)
3881 1625 stunclk=160;
3882
3883
3/4
✓ Branch 0 taken 1625 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549 times.
✓ Branch 3 taken 1076 times.
1625 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3884 {
3885
1/2
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
549 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3886 549 goto hitclock;
3887 }
3888
3889 1076 break;
3890 }
3891
3892
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
148 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult();
3893 else
3894 45 hp-=power;
3895
3896 148 goto hitclock;
3897 }
3898 break;
3899
3900 case wHSHandle:
3901 {
3902
3/4
✓ Branch 0 taken 9056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✓ Branch 3 taken 8533 times.
9056 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & item_flag1)
3903 523 return 0;
3904
3905
3/4
✓ Branch 0 taken 6093 times.
✓ Branch 1 taken 2440 times.
✓ Branch 2 taken 2440 times.
✗ Branch 3 not taken.
8533 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3906
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2440 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3907
3908 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3909
6/8
✓ Branch 0 taken 2787 times.
✓ Branch 1 taken 5746 times.
✓ Branch 2 taken 2787 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2787 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 502 times.
✓ Branch 7 taken 2285 times.
10245 if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot)
3910
6/6
✓ Branch 0 taken 3375 times.
✓ Branch 1 taken 2873 times.
✓ Branch 2 taken 1771 times.
✓ Branch 3 taken 3889 times.
✓ Branch 4 taken 1712 times.
✓ Branch 5 taken 2177 times.
2787 || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(guy_shield_back|guy_shield_front|guy_shield_left|guy_shield_right))))
3911 2177 return 0;
3912
3913 12102 power = game->get_hero_dmgmult();
3914 12571 }
3915
3916 fsparkle:
3917
3918 [[fallthrough]];
3919 default:
3920 // Work out the defenses!
3921 {
3922 98477 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3923
3924
2/2
✓ Branch 0 taken 26476 times.
✓ Branch 1 taken 72001 times.
98477 if(def >= 0)
3925 26476 return def;
3926
2/2
✓ Branch 0 taken 71541 times.
✓ Branch 1 taken 460 times.
72001 else if(def == -2)
3927 {
3928 460 ret = 0;
3929 460 }
3930 }
3931
3932
2/2
✓ Branch 0 taken 71999 times.
✓ Branch 1 taken 2 times.
144002 if(!power)
3933 {
3934
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
3935 2 hp-=1;
3936 else
3937 {
3938 // Don't make a long chain of 'stun' hits
3939 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3940 return 1;
3941
3942
3943 if(!switch_hooked)
3944 stunclk=160;
3945 break;
3946 }
3947 2 }
3948 71999 else hp-=power;
3949
3950 hitclock:
3951 77198 hclk=33;
3952
3953 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3954
2/2
✓ Branch 0 taken 34515 times.
✓ Branch 1 taken 42683 times.
77198 if((dir&2)==(w->dir&2))
3955 {
3956 42683 sclk=(w->dir<<8)+16;
3957 42683 }
3958 77198 }
3959
3960
5/6
✓ Branch 0 taken 73785 times.
✓ Branch 1 taken 19558 times.
✓ Branch 2 taken 21969 times.
✓ Branch 3 taken 71374 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21969 times.
93343 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3961 {
3962 21969 fading=fade_blue_poof;
3963 21969 }
3964
3965
6/6
✓ Branch 0 taken 88410 times.
✓ Branch 1 taken 4933 times.
✓ Branch 2 taken 46745 times.
✓ Branch 3 taken 41665 times.
✓ Branch 4 taken 2155 times.
✓ Branch 5 taken 44590 times.
93343 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3966 {
3967
2/2
✓ Branch 0 taken 7081 times.
✓ Branch 1 taken 7 times.
7088 if( hitsfx > 0 ) //user-set hit sound.
3968 {
3969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7081 times.
7081 if (!dying) //don't play the hit sound on death! -Z
3970 7081 sfx(hitsfx, pan(int32_t(x)));
3971 7081 }
3972 7 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one.
3973 7088 }
3974 else //2.50.2 or earlier
3975 {
3976 86255 sfx(WAV_EHIT, pan(int32_t(x)));
3977 86255 sfx(hitsfx, pan(int32_t(x)));
3978 }
3979
2/2
✓ Branch 0 taken 93314 times.
✓ Branch 1 taken 29 times.
93343 if(family==eeGUY)
3980 29 sfx(WAV_EDEAD, pan(int32_t(x)));
3981
3982 // Penetrating weapons
3983
4/4
✓ Branch 0 taken 91482 times.
✓ Branch 1 taken 1861 times.
✓ Branch 2 taken 84583 times.
✓ Branch 3 taken 8760 times.
93343 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3984 {
3985 8760 int32_t item=enemyHitWeapon;
3986
3987
2/2
✓ Branch 0 taken 1599 times.
✓ Branch 1 taken 7161 times.
8760 if(wpnId==wArrow)
3988 {
3989 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3990
5/6
✓ Branch 0 taken 1484 times.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 1105 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 379 times.
1599 if(item>=0 && (itemsbuf[item].flags&item_flag1) && (itemsbuf[parent_item].family == itype_arrow))
3991 379 return 0;
3992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1220 times.
1220 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3993 //if(item<0)
3994 else
3995 1220 item=current_item_id(itype_arrow);
3996 1220 }
3997
3998 else
3999 {
4000
4001 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
4002
3/6
✓ Branch 0 taken 7143 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7143 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7161 if(item>=0 && (itemsbuf[item].flags&item_flag3) && (itemsbuf[parent_item].family == itype_sword))
4003 return 0;
4004
4005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7161 times.
7161 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
4006 else
4007 //if(item<0)
4008 7161 item=current_item_id(itype_sword);
4009 }
4010 8381 }
4011
4012 92964 return ret;
4013 268817 }
4014
4015 61491740 bool enemy::dont_draw()
4016 {
4017
6/6
✓ Branch 0 taken 61028954 times.
✓ Branch 1 taken 462786 times.
✓ Branch 2 taken 60958047 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 171995 times.
✓ Branch 5 taken 60856959 times.
61491740 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4018 634781 return true;
4019
4020
2/2
✓ Branch 0 taken 1371477 times.
✓ Branch 1 taken 59485482 times.
60856959 if(flags&guy_invisible)
4021 1371477 return true;
4022
4023
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 59485050 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
59485482 if(flags&guy_lens_only && !lensclk)
4024 return true;
4025
4026 59485482 return false;
4027 61491740 }
4028
4029 #define DRAW_NORMAL 2
4030 #define DRAW_CLOAKED 1
4031 #define DRAW_INVIS 0
4032 // base drawing function to be used by all derived classes instead of
4033 // sprite::draw()
4034 44700316 void enemy::draw(BITMAP *dest)
4035 {
4036 44700316 didScriptThisFrame = false; //Since there's no better place to put it
4037
6/6
✓ Branch 0 taken 43936911 times.
✓ Branch 1 taken 763405 times.
✓ Branch 2 taken 43854261 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 314518 times.
✓ Branch 5 taken 43622393 times.
44700316 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4038 1077923 return;
4039
2/2
✓ Branch 0 taken 2767665 times.
✓ Branch 1 taken 40854728 times.
43622393 if(flags&guy_invisible)
4040 2767665 return;
4041
4042 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
4043 // be cloaked if they have "invisible displays as cloaked" checked.
4044
4045 40854728 byte canSee = DRAW_NORMAL;
4046 //Enemy specific stuff
4047
2/2
✓ Branch 0 taken 40853564 times.
✓ Branch 1 taken 1164 times.
40854728 if ( editorflags & ENEMY_FLAG1 )
4048 {
4049 1164 canSee = DRAW_INVIS;
4050
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4051
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4052 {
4053 if (game->item[dmisc13])
4054 {
4055 canSee = DRAW_NORMAL;
4056 }
4057 //else if ( lensclk && getlensid.flags SHOWINVIS )
4058 //{
4059 //
4060 //}
4061 //else
4062 //{
4063 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4064 // //otherwisem invisible
4065 //}
4066 }
4067 1164 }
4068 //Room specific
4069
2/2
✓ Branch 0 taken 38683529 times.
✓ Branch 1 taken 2171199 times.
40854728 if (tmpscr->flags3&fINVISROOM)
4070 {
4071
4/6
✓ Branch 0 taken 2171199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226004 times.
✓ Branch 3 taken 1945195 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 226004 times.
2397203 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226004 times.
226004 !((itemsbuf[Hero.getLastLensID()].flags & item_flag5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED;
4073 2171199 }
4074 //Lens check
4075
2/2
✓ Branch 0 taken 27345 times.
✓ Branch 1 taken 40827383 times.
40854728 if (lensclk)
4076 {
4077
2/2
✓ Branch 0 taken 26913 times.
✓ Branch 1 taken 432 times.
27345 if(flags&guy_lens_only)
4078 {
4079
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4080 432 }
4081 27345 }
4082 else
4083 {
4084
2/2
✓ Branch 0 taken 40753967 times.
✓ Branch 1 taken 73416 times.
40827383 if(flags&guy_lens_only)
4085 73416 canSee = DRAW_INVIS;
4086 }
4087
3/4
✓ Branch 0 taken 74580 times.
✓ Branch 1 taken 40780148 times.
✓ Branch 2 taken 74580 times.
✗ Branch 3 not taken.
40854728 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4088
3/4
✓ Branch 0 taken 40554144 times.
✓ Branch 1 taken 300584 times.
✓ Branch 2 taken 40554144 times.
✗ Branch 3 not taken.
40854728 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4089
4090
2/2
✓ Branch 0 taken 40780148 times.
✓ Branch 1 taken 74580 times.
40854728 if (canSee == DRAW_INVIS)
4091 74580 return;
4092
4093
4/4
✓ Branch 0 taken 40777842 times.
✓ Branch 1 taken 2306 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 40777835 times.
40780148 if(fallclk||drownclk)
4094 {
4095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2313 times.
2313 if (canSee == DRAW_CLOAKED)
4096 {
4097 sprite::drawcloaked(dest);
4098 }
4099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2313 times.
2313 else if (canSee == DRAW_NORMAL)
4100 {
4101 2313 sprite::draw(dest);
4102 2313 }
4103 2313 return;
4104 }
4105 40777835 int32_t cshold=cs;
4106
4107
2/2
✓ Branch 0 taken 901525 times.
✓ Branch 1 taken 39876310 times.
40777835 if(dying)
4108 {
4109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 901525 times.
901525 if(clk2>=19)
4110 {
4111 if(!(clk2&2))
4112 {
4113 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4114 if (canSee == DRAW_CLOAKED)
4115 {
4116 sprite::drawcloaked(dest);
4117 }
4118 else if (canSee == DRAW_NORMAL)
4119 {
4120 sprite::draw(dest);
4121 }
4122 }
4123 return;
4124 }
4125
4126 901525 flip = 0;
4127 901525 tile = wpnsbuf[spr_death].tile;
4128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 901525 times.
901525 if ( do_animation )
4129 {
4130 901525 int32_t offs = 0;
4131
2/2
✓ Branch 0 taken 850658 times.
✓ Branch 1 taken 50867 times.
901525 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4132 {
4133
2/2
✓ Branch 0 taken 49251 times.
✓ Branch 1 taken 1616 times.
50867 if(clk2 > 2)
4134 {
4135 1616 spr_death_anim_clk=0;
4136 1616 clk2=1;
4137
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1602 times.
1616 if(hp > -1000)
4138 1602 death_sfx();
4139 1616 }
4140
4/4
✓ Branch 0 taken 38168 times.
✓ Branch 1 taken 12699 times.
✓ Branch 2 taken 402 times.
✓ Branch 3 taken 37766 times.
50867 if(clk2==1 && spr_death_anim_clk>-1)
4141 {
4142 37766 ++clk2;
4143
2/2
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35384 times.
37766 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4144
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 37745 times.
37766 spr_death_anim_frm *= zc_max(1,txsz);
4145 37766 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4146
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 37690 times.
37766 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4147
6/6
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35384 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 37764 times.
✓ Branch 4 taken 36168 times.
✓ Branch 5 taken 1598 times.
37766 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4148 {
4149 1598 spr_death_anim_clk=-1;
4150 1598 clk2=1;
4151 1598 }
4152 37766 }
4153 50867 tile += spr_death_anim_frm;
4154 50867 }
4155
2/2
✓ Branch 0 taken 313513 times.
✓ Branch 1 taken 537145 times.
850658 else if(BSZ)
4156 {
4157
2/2
✓ Branch 0 taken 246522 times.
✓ Branch 1 taken 66991 times.
313513 offs = zc_min((15-clk2)/3,4);
4158 313513 }
4159
4/4
✓ Branch 0 taken 358175 times.
✓ Branch 1 taken 178970 times.
✓ Branch 2 taken 178959 times.
✓ Branch 3 taken 179216 times.
537145 else if(clk2>6 && clk2<=12)
4160 {
4161 179216 offs = 1;
4162 179216 }
4163
4164
2/2
✓ Branch 0 taken 454946 times.
✓ Branch 1 taken 446579 times.
901525 if(offs)
4165 {
4166
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 446129 times.
446579 offs *= zc_max(1,txsz);
4167 446579 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4168
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 446141 times.
446579 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4169 446579 }
4170 901525 tile += offs;
4171 901525 }
4172
4173
6/6
✓ Branch 0 taken 850658 times.
✓ Branch 1 taken 50867 times.
✓ Branch 2 taken 537145 times.
✓ Branch 3 taken 313513 times.
✓ Branch 4 taken 189182 times.
✓ Branch 5 taken 347963 times.
901525 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4174 553562 cs = wpnsbuf[spr_death].csets&15;
4175 else
4176 347963 cs = (((clk2+5)>>1)&3)+6;
4177 901525 }
4178
3/4
✓ Branch 0 taken 1189380 times.
✓ Branch 1 taken 38686930 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1189380 times.
39876310 else if(hclk>0 && getCanFlicker())
4179 {
4180 1189380 cs = getFlashingCSet();
4181 1189380 }
4182 //draw every other frame for flickering enemies
4183
2/2
✓ Branch 0 taken 248031 times.
✓ Branch 1 taken 40529804 times.
40777835 if (is_hitflickerframe(false))
4184 {
4185
5/6
✓ Branch 0 taken 90246 times.
✓ Branch 1 taken 157785 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 90245 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 157786 times.
248031 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4186
2/4
✓ Branch 0 taken 248031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248031 times.
248031 if (game->get_spriteflickercolor() || temp_flicker_color)
4187 {
4188 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4189 sprite_flicker_color = temp_flicker_color;
4190 sprite::draw(dest);
4191 }
4192 248031 }
4193 else
4194 {
4195
2/2
✓ Branch 0 taken 225162 times.
✓ Branch 1 taken 40304642 times.
40529804 if (canSee == DRAW_CLOAKED)
4196 {
4197 225162 sprite::drawcloaked(dest);
4198 225162 }
4199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40304642 times.
40304642 else if (canSee == DRAW_NORMAL)
4200 {
4201
1/2
✓ Branch 0 taken 40304642 times.
✗ Branch 1 not taken.
40304642 if ( frozenclock < 0 )
4202 {
4203 if ( frozentile > 0 ) tile = frozentile;
4204 loadpalset(csBOSS,frozencset);
4205 }
4206 40304642 sprite::draw(dest);
4207 40304642 }
4208 }
4209 40777835 cs=cshold;
4210 44700316 }
4211
4212 //old zc bosses
4213 40751050 void enemy::drawzcboss(BITMAP *dest)
4214 {
4215 40751050 didScriptThisFrame = false; //Since there's no better place to put it
4216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40751050 times.
40751050 if(dont_draw())
4217 return;
4218
4219 40751050 int32_t cshold=cs;
4220
4221
2/2
✓ Branch 0 taken 781584 times.
✓ Branch 1 taken 39969466 times.
40751050 if(dying)
4222 {
4223
2/2
✓ Branch 0 taken 3960 times.
✓ Branch 1 taken 777624 times.
781584 if(clk2>=19)
4224 {
4225
2/2
✓ Branch 0 taken 1980 times.
✓ Branch 1 taken 1980 times.
3960 if(!(clk2&2))
4226 1980 sprite::drawzcboss(dest);
4227
4228 3960 return;
4229 }
4230
4231 777624 flip = 0;
4232 777624 tile = wpnsbuf[spr_death].tile;
4233
4234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 777624 times.
777624 if ( do_animation )
4235 {
4236
2/2
✓ Branch 0 taken 773108 times.
✓ Branch 1 taken 4516 times.
777624 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4237 {
4238
2/2
✓ Branch 0 taken 4510 times.
✓ Branch 1 taken 6 times.
4516 if(clk2 > 2)
4239 {
4240 6 spr_death_anim_clk=0;
4241 6 clk2=1;
4242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(hp > -1000)
4243 6 death_sfx();
4244 6 }
4245
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 4256 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 76 times.
4516 if(clk2==1 && spr_death_anim_clk>-1)
4246 {
4247 76 ++clk2;
4248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm *= zc_max(1,txsz);
4250 76 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4252
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 2 times.
76 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4253 {
4254 2 spr_death_anim_clk=-1;
4255 2 clk2=1;
4256 2 }
4257 76 }
4258 4516 tile += spr_death_anim_frm;
4259 4516 }
4260
2/2
✓ Branch 0 taken 276492 times.
✓ Branch 1 taken 496616 times.
773108 else if(BSZ)
4261
2/2
✓ Branch 0 taken 217484 times.
✓ Branch 1 taken 59008 times.
276492 tile += zc_min((15-clk2)/3,4);
4262
4/4
✓ Branch 0 taken 331041 times.
✓ Branch 1 taken 165575 times.
✓ Branch 2 taken 165418 times.
✓ Branch 3 taken 165623 times.
496616 else if(clk2>6 && clk2<=12)
4263 165623 ++tile;
4264 777624 }
4265
4266
6/6
✓ Branch 0 taken 773108 times.
✓ Branch 1 taken 4516 times.
✓ Branch 2 taken 496616 times.
✓ Branch 3 taken 276492 times.
✓ Branch 4 taken 183872 times.
✓ Branch 5 taken 312744 times.
777624 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4267 464880 cs = wpnsbuf[spr_death].csets&15;
4268 else
4269 312744 cs = (((clk2+5)>>1)&3)+6;
4270 777624 }
4271
2/2
✓ Branch 0 taken 38769460 times.
✓ Branch 1 taken 1200006 times.
39969466 else if(hclk>0)
4272 {
4273 1200006 cs = getFlashingCSet();
4274 1200006 }
4275
4276
3/4
✓ Branch 0 taken 2045619 times.
✓ Branch 1 taken 38701471 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7543 times.
40754633 if((tmpscr->flags3&fINVISROOM) &&
4277
2/2
✓ Branch 0 taken 7543 times.
✓ Branch 1 taken 2038076 times.
2045619 !(current_item(itype_amulet)) &&
4278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7543 times.
7543 !(get_qr(qr_LENSSEESENEMIES) &&
4279 7543 lensclk) && family!=eeGANON)
4280 {
4281 7543 sprite::drawcloaked(dest);
4282 7543 }
4283 else
4284 {
4285
2/2
✓ Branch 0 taken 23473 times.
✓ Branch 1 taken 40716074 times.
40739547 if (is_hitflickerframe(true))
4286 {
4287
4/6
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 22588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 885 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22588 times.
23473 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4288
1/2
✓ Branch 0 taken 23473 times.
✗ Branch 1 not taken.
23473 if (game->get_spriteflickercolor())
4289 {
4290 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4291 sprite_flicker_color = temp_flicker_color;
4292 sprite::drawzcboss(dest);
4293 }
4294 23473 }
4295 else
4296 40716074 sprite::drawzcboss(dest);
4297 }
4298
4299 40747090 cs=cshold;
4300 40751050 }
4301
4302
4303 // similar to the overblock function--can do up to a 32x32 sprite
4304 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4305 323235 void enemy::drawblock(BITMAP *dest,int32_t mask)
4306 {
4307 323235 int32_t thold=tile;
4308 323235 int32_t t1=tile;
4309 323235 int32_t t2=tile+20;
4310 323235 int32_t t3=tile+1;
4311 323235 int32_t t4=tile+21;
4312
4313
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 323235 times.
323235 switch(mask)
4314 {
4315 case 1:
4316 enemy::drawzcboss(dest);
4317 break;
4318
4319 case 3:
4320 if(flip&2)
4321 zc_swap(t1,t2);
4322
4323 tile=t1;
4324 enemy::drawzcboss(dest);
4325 tile=t2;
4326 yofs+=16;
4327 enemy::drawzcboss(dest);
4328 yofs-=16;
4329 break;
4330
4331 case 5:
4332 t2=tile+1;
4333
4334 if(flip&1)
4335 zc_swap(t1,t2);
4336
4337 tile=t1;
4338 enemy::drawzcboss(dest);
4339 tile=t2;
4340 xofs+=16;
4341 enemy::drawzcboss(dest);
4342 xofs-=16;
4343 break;
4344
4345 case 15:
4346
2/2
✓ Branch 0 taken 316479 times.
✓ Branch 1 taken 6756 times.
323235 if(flip&1)
4347 {
4348 6756 zc_swap(t1,t3);
4349 6756 zc_swap(t2,t4);
4350 6756 }
4351
4352
1/2
✓ Branch 0 taken 323235 times.
✗ Branch 1 not taken.
323235 if(flip&2)
4353 {
4354 zc_swap(t1,t2);
4355 zc_swap(t3,t4);
4356 }
4357
4358 323235 tile=t1;
4359 323235 enemy::drawzcboss(dest);
4360 323235 tile=t2;
4361 323235 yofs+=16;
4362 323235 enemy::drawzcboss(dest);
4363 323235 yofs-=16;
4364 323235 tile=t3;
4365 323235 xofs+=16;
4366 323235 enemy::drawzcboss(dest);
4367 323235 tile=t4;
4368 323235 yofs+=16;
4369 323235 enemy::drawzcboss(dest);
4370 323235 xofs-=16;
4371 323235 yofs-=16;
4372 323235 break;
4373 }
4374
4375 323235 tile=thold;
4376 323235 }
4377
4378 20176865 void enemy::drawshadow(BITMAP *dest, bool translucent)
4379 {
4380
4/4
✓ Branch 0 taken 18170607 times.
✓ Branch 1 taken 2006258 times.
✓ Branch 2 taken 406089 times.
✓ Branch 3 taken 17764518 times.
20176865 if(dont_draw() || isSideViewGravity())
4381 {
4382 2412347 return;
4383 }
4384
4385
2/2
✓ Branch 0 taken 326866 times.
✓ Branch 1 taken 17437652 times.
17764518 if(dying)
4386 {
4387 326866 return;
4388 }
4389
4390
4/4
✓ Branch 0 taken 1718249 times.
✓ Branch 1 taken 15719403 times.
✓ Branch 2 taken 347010 times.
✓ Branch 3 taken 17090642 times.
17437652 if(((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4391 17437652 (darkroom))
4392 {
4393 347010 return;
4394 }
4395 else
4396 {
4397
4/4
✓ Branch 0 taken 16516736 times.
✓ Branch 1 taken 573906 times.
✓ Branch 2 taken 16469365 times.
✓ Branch 3 taken 47371 times.
17090642 if(enemycanfall(id, false) && shadowtile == 0)
4398 47371 shadowtile = wpnsbuf[spr_shadow].tile;
4399
4400
5/6
✓ Branch 0 taken 16152278 times.
✓ Branch 1 taken 938364 times.
✓ Branch 2 taken 16152278 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15578372 times.
✓ Branch 5 taken 573906 times.
17090642 if(z>0 || fakez>0 || !enemycanfall(id, false))
4401 {
4402
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 1511995 times.
1512270 if(!shadow_overpit(this))
4403 1511995 sprite::drawshadow(dest,translucent);
4404 1512270 }
4405 }
4406 20176865 }
4407
4408 129181 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4409 {
4410 129181 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4411
4412
1/2
✓ Branch 0 taken 129181 times.
✗ Branch 1 not taken.
129181 if(sub!=NULL)
4413 {
4414 129181 xofs-=mx;
4415 129181 yofs-=my;
4416 129181 enemy::draw(sub);
4417 129181 xofs+=mx;
4418 129181 yofs+=my;
4419 129181 destroy_bitmap(sub);
4420 129181 }
4421 else
4422 enemy::draw(dest);
4423 129181 }
4424
4425 9 void enemy::init_size_flags()
4426 {
4427
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; }
4428
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
4429
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
4430
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
4431
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
4432
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
4433
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
4434
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
4435
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
4436 {
4437 yofs = (int32_t)d->yofs;
4438 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset);
4439 }
4440
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
4441 9 }
4442
4443 // override hit detection to check for invicibility, stunned, etc
4444 112146621 bool enemy::hit()
4445 {
4446
4/4
✓ Branch 0 taken 110823541 times.
✓ Branch 1 taken 1323080 times.
✓ Branch 2 taken 109028765 times.
✓ Branch 3 taken 1794776 times.
112146621 if(dying || hclk>0) return false;
4447 109028765 return sprite::hit();
4448 112146621 }
4449 730351 bool enemy::hit(sprite *s)
4450 {
4451
3/4
✓ Branch 0 taken 730351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 713374 times.
✓ Branch 3 taken 16977 times.
730351 if(!hit() || !s->hit()) return false;
4452 713374 return sprite::hit(s);
4453 730351 }
4454
4455 44499041 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4456 {
4457
2/2
✓ Branch 0 taken 3918687 times.
✓ Branch 1 taken 40580354 times.
44499041 if(!hit()) return false;
4458 40580354 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4459 44499041 }
4460 78011 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4461 {
4462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78011 times.
78011 if(!hit()) return false;
4463 78011 return sprite::hit(tx,ty,txsz2,tysz2);
4464 78011 }
4465
4466 11132690 bool enemy::hit(weapon *w)
4467 {
4468
2/2
✓ Branch 0 taken 1172238 times.
✓ Branch 1 taken 9960452 times.
11132690 if(!hit()) return false;
4469
4470
2/2
✓ Branch 0 taken 6645889 times.
✓ Branch 1 taken 3314563 times.
9960452 if (replay_version_check(0, 14))
4471 {
4472
4/6
✓ Branch 0 taken 6421582 times.
✓ Branch 1 taken 224307 times.
✓ Branch 2 taken 6421582 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6421582 times.
✗ Branch 5 not taken.
6645889 if(!w->scriptcoldet || w->fallclk || w->drownclk)
4473 224307 return false;
4474 6421582 return sprite::hit(w);
4475 }
4476 3314563 return w->hit(this);
4477 11132690 }
4478
4479 9454558 bool enemy::can_pitfall(bool checkspawning)
4480 {
4481
4/4
✓ Branch 0 taken 9434867 times.
✓ Branch 1 taken 19691 times.
✓ Branch 2 taken 9424212 times.
✓ Branch 3 taken 30346 times.
9454558 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4482
2/2
✓ Branch 0 taken 9406553 times.
✓ Branch 1 taken 17659 times.
9424212 switch(guysbuf[id&0xFFF].family)
4483 {
4484 case eeAQUA:
4485 case eeDIG:
4486 case eeDONGO:
4487 case eeFAIRY:
4488 case eeGANON:
4489 case eeGHOMA:
4490 case eeGLEEOK:
4491 case eeGUY:
4492 case eeLANM:
4493 case eeMANHAN:
4494 case eeMOLD:
4495 case eeNONE:
4496 case eePATRA:
4497 case eeZORA:
4498 17659 return false; //Disallowed types
4499 default:
4500 9406553 return true;
4501 }
4502 9454558 }
4503 //Handle death
4504 37821672 void enemy::try_death(bool force_kill)
4505 {
4506
8/8
✓ Branch 0 taken 37766717 times.
✓ Branch 1 taken 54955 times.
✓ Branch 2 taken 37766706 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 43493 times.
✓ Branch 5 taken 37723213 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 43492 times.
37821672 if(!dying && (force_kill || (hp<=0 && !immortal)))
4507 {
4508 43503 std::vector<int32_t> &ev = FFCore.eventData;
4509 43503 ev.clear();
4510 43503 ev.push_back(10000);
4511 43503 ev.push_back(getUID());
4512
4513 43503 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4514 43503 bool isSaved = !ev[0];
4515 43503 ev.clear();
4516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43503 times.
43503 if(isSaved) return;
4517
4518
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 43455 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 42 times.
43503 if(itemguy && (hasitem&2)!=0)
4519 {
4520
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 42 times.
89 for(int32_t i=0; i<items.Count(); i++)
4521 {
4522
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 42 times.
47 if(((item*)items.spr(i))->pickup&ipENEMY)
4523 {
4524
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 1 times.
42 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4525 {
4526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4527 {
4528 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4529 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4530 }
4531 else
4532 {
4533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(extend >= 3)
4534 {
4535 items.spr(i)->x = x+(txsz-1)*8;
4536 items.spr(i)->y = y-2+(tysz-1)*8;
4537 }
4538 else
4539 {
4540 1 items.spr(i)->x = x;
4541 1 items.spr(i)->y = y - 2;
4542 }
4543 }
4544 1 items.spr(i)->z = z;
4545 1 items.spr(i)->fakez = fakez;
4546 1 }
4547 else
4548 {
4549 41 items.spr(i)->x = x;
4550 41 items.spr(i)->y = y - 2;
4551 }
4552 42 }
4553 47 }
4554 42 }
4555
4556 43503 dying=true;
4557
4558
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 43471 times.
43503 if(fading==fade_flash_die)
4559 32 clk2=19+18*4;
4560 else
4561 {
4562 43471 clk2 = BSZ ? 15 : 19;
4563
4564
2/2
✓ Branch 0 taken 21051 times.
✓ Branch 1 taken 22420 times.
43471 if(fading!=fade_blue_poof)
4565 22420 fading=0;
4566 }
4567
4568
2/2
✓ Branch 0 taken 43455 times.
✓ Branch 1 taken 48 times.
43503 if(itemguy)
4569 {
4570 48 hasitem&=~2;
4571 48 item_set=0;
4572 48 }
4573
4574
6/6
✓ Branch 0 taken 42449 times.
✓ Branch 1 taken 1054 times.
✓ Branch 2 taken 33764 times.
✓ Branch 3 taken 8685 times.
✓ Branch 4 taken 1413 times.
✓ Branch 5 taken 32351 times.
43503 if(currscr<128 && count_enemy && !script_spawned)
4575 32351 game->guys[(currmap<<7)+currscr]-=1;
4576 43503 }
4577 37821672 }
4578
4579 // --==**==--
4580
4581 // Movement routines that can be used by derived classes as needed
4582
4583 // --==**==--
4584
4585 555795 void enemy::fix_coords(bool bound)
4586 {
4587
1/2
✓ Branch 0 taken 555795 times.
✗ Branch 1 not taken.
555795 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 555795 times.
555795 if(moveflags & move_ignore_screenedge) bound = false;
4589
4590
4591
2/2
✓ Branch 0 taken 81680 times.
✓ Branch 1 taken 474115 times.
555795 if(bound)
4592 {
4593
1/2
✓ Branch 0 taken 474115 times.
✗ Branch 1 not taken.
474115 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4594 {
4595
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474113 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
474115 x=vbound(x, 0_zf, (( guysbuf[id].SIZEflags&OVERRIDE_TILE_WIDTH && !isflier(id) ) ? (256_zf -((txsz-1)*16)) : 240_zf));
4596
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474113 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
474115 y=vbound(y, 0_zf,(( guysbuf[id].SIZEflags&OVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (176_zf -((txsz-1)*16)) : 160_zf));
4597 474115 }
4598 else
4599 {
4600 x=vbound(x, 0_zf,240_zf);
4601 y=vbound(y, 0_zf,160_zf);
4602 }
4603 474115 }
4604
4605
6/10
✓ Branch 0 taken 554781 times.
✓ Branch 1 taken 1014 times.
✓ Branch 2 taken 555795 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 555795 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 555795 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 555795 times.
555795 if(!OUTOFBOUNDS)
4606 {
4607 /*x=((int32_t(x)&0xF0)+((int32_t(x)&8)?16:0));
4608
4609 if(isSideViewGravity())
4610 y=((int32_t(y)&0xF8)+((int32_t(y)&4)?8:0));
4611 else
4612 y=((int32_t(y)&0xF0)+((int32_t(y)&8)?16:0));
4613 */
4614 555795 do_fix(x, 16, true);
4615
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 554781 times.
555795 if(isSideViewGravity())
4616 1014 do_fix(y,8,true);
4617 554781 else do_fix(y,16,true);
4618 555795 }
4619 555795 }
4620 9156 bool enemy::cannotpenetrate()
4621 {
4622
4/4
✓ Branch 0 taken 8975 times.
✓ Branch 1 taken 181 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 8937 times.
9156 return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA);
4623 }
4624
4625 562 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4626 {
4627 bool ok;
4628 562 int32_t dx = 0, dy = 0;
4629 562 int32_t sv = 8;
4630
4631 //Why is this here??? Why is it needed???
4632 562 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4633
4634
8/9
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 78 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 81 times.
✗ Branch 8 not taken.
562 switch(ndir)
4635 {
4636 case 8:
4637 case up:
4638
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
69 if(canfall(id) && isSideViewGravity())
4639 return false;
4640
4641 69 dy = dy1-s;
4642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 special = (special==spw_clipbottomright)?spw_none:special;
4643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4644 69 break;
4645
4646 case 12:
4647 case down:
4648
3/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
51 if(canfall(id) && isSideViewGravity())
4649 return false;
4650
4651 51 dy = dy2+s;
4652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4653 51 break;
4654
4655 case 14:
4656 case left:
4657 47 dx = dx1-s;
4658 47 sv = ((isSideViewGravity())?7:8);
4659
2/4
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4660
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 45 times.
47 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4661 47 break;
4662
4663 case 10:
4664 case right:
4665 85 dx = dx2+s;
4666 85 sv = ((isSideViewGravity())?7:8);
4667
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 79 times.
85 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4668 85 break;
4669
4670 case 9:
4671 case r_up:
4672 94 dx = dx2+s;
4673 94 dy = dy1-s;
4674
3/4
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 1 times.
187 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4676 94 break;
4677
4678 case 11:
4679 case r_down:
4680 78 dx = dx2+s;
4681 78 dx = dy2+s;
4682
3/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 1 times.
155 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4684 78 break;
4685
4686 case 13:
4687 case l_down:
4688 57 dx = dx1-s;
4689 57 dy = dy2+s;
4690
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4692 57 break;
4693
4694 case 15:
4695 case l_up:
4696 81 dx = dx1-s;
4697 81 dy = dy1-s;
4698
3/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 1 times.
161 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4700 81 break;
4701
4702 default:
4703 db=99;
4704 return true;
4705 }
4706
4707 562 return ok;
4708 562 }
4709
4710
4711
4712
4713 // returns true if next step is ok, false if there is something there
4714 7325199 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4715 {
4716 7325199 bool ok = false; //initialise the var, son't just declare it
4717 7325199 int32_t dx = 0, dy = 0;
4718 7325199 int32_t sv = 8;
4719 7325199 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4720 //Why is this here??? Why is it needed???
4721 7325199 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7325199 times.
7325199 int32_t usexoffs = (SIZEflags&OVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7325199 times.
7325199 int32_t useyoffs = (SIZEflags&OVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4724
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7325186 times.
7325199 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4725
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7325186 times.
7325199 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4726 7325199 bool offgrid = OFFGRID_ENEMY;
4727
2/2
✓ Branch 0 taken 7291 times.
✓ Branch 1 taken 7317908 times.
7325199 if(!offgrid)
4728 {
4729 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4730
1/2
✓ Branch 0 taken 7317908 times.
✗ Branch 1 not taken.
7317908 if(usehei<16)usehei=16;
4731
1/2
✓ Branch 0 taken 7317908 times.
✗ Branch 1 not taken.
7317908 if(usewid<16)usewid=16;
4732 7317908 }
4733
9/9
✓ Branch 0 taken 1327873 times.
✓ Branch 1 taken 1102917 times.
✓ Branch 2 taken 1221995 times.
✓ Branch 3 taken 1212911 times.
✓ Branch 4 taken 536645 times.
✓ Branch 5 taken 638123 times.
✓ Branch 6 taken 600184 times.
✓ Branch 7 taken 564898 times.
✓ Branch 8 taken 119653 times.
7325199 switch(ndir) //need to check every 8 pixels between two points
4734 {
4735 case 8:
4736 case up:
4737 {
4738
4/4
✓ Branch 0 taken 150619 times.
✓ Branch 1 taken 1177254 times.
✓ Branch 2 taken 150029 times.
✓ Branch 3 taken 590 times.
1327873 if(enemycanfall(id) && isSideViewGravity())
4739 590 return false;
4740
4741 1327283 dy = dy1-s;
4742
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1326803 times.
1327283 special = (special==spw_clipbottomright)?spw_none:special;
4743 1327283 tries = usewid/(offgrid ? 8 : 16);
4744 //Z_eventlog("Trying move UP, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4745
2/2
✓ Branch 0 taken 1127175 times.
✓ Branch 1 taken 1327933 times.
2455108 for ( ; tries > 0; --tries )
4746 {
4747
2/2
✓ Branch 0 taken 197488 times.
✓ Branch 1 taken 1130445 times.
1327933 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4748 1327933 try_x += (offgrid ? 8 : 16);
4749
2/2
✓ Branch 0 taken 1127825 times.
✓ Branch 1 taken 200108 times.
1327933 if (!ok) break;
4750 1127825 }
4751
2/2
✓ Branch 0 taken 1127175 times.
✓ Branch 1 taken 200108 times.
1327283 if(!ok) break;
4752
1/2
✓ Branch 0 taken 1127175 times.
✗ Branch 1 not taken.
1127175 if((usewid%16)>0) //Uneven width
4753 {
4754 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4755 }
4756 1127175 break;
4757 }
4758 case 12:
4759 case down:
4760 {
4761
4/4
✓ Branch 0 taken 180547 times.
✓ Branch 1 taken 922370 times.
✓ Branch 2 taken 179859 times.
✓ Branch 3 taken 688 times.
1102917 if(enemycanfall(id) && isSideViewGravity())
4762 688 return false;
4763
4764 1102229 dy = dy2+s;
4765 1102229 tries = usewid/(offgrid ? 8 : 16);
4766 //Z_eventlog("Trying move DOWN, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4767
2/2
✓ Branch 0 taken 896238 times.
✓ Branch 1 taken 1103013 times.
1999251 for ( ; tries > 0; --tries )
4768 {
4769
3/4
✓ Branch 0 taken 205243 times.
✓ Branch 1 taken 897770 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 897770 times.
1103013 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4770 1103013 try_x += (offgrid ? 8 : 16);
4771
2/2
✓ Branch 0 taken 897022 times.
✓ Branch 1 taken 205991 times.
1103013 if (!ok) break;
4772 897022 }
4773
2/2
✓ Branch 0 taken 896238 times.
✓ Branch 1 taken 205991 times.
1102229 if(!ok) break;
4774
1/2
✓ Branch 0 taken 896238 times.
✗ Branch 1 not taken.
896238 if((usewid%16)>0) //Uneven width
4775 {
4776 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4777 }
4778 896238 break;
4779 }
4780 case 14:
4781 case left:
4782 {
4783 1221995 dx = dx1-s;
4784 1221995 sv = ((isSideViewGravity())?7:0);
4785
4/4
✓ Branch 0 taken 1221372 times.
✓ Branch 1 taken 623 times.
✓ Branch 2 taken 1768 times.
✓ Branch 3 taken 1219604 times.
1221995 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4786 1221995 tries = usehei/(offgrid ? 8 : 16);
4787 //Z_eventlog("Trying move LEFT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4788
2/2
✓ Branch 0 taken 1023070 times.
✓ Branch 1 taken 1222912 times.
2245982 for ( ; tries > 0; --tries )
4789 {
4790
2/2
✓ Branch 0 taken 197742 times.
✓ Branch 1 taken 1025170 times.
1222912 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4791 1222912 try_y += (offgrid ? 8 : 16);
4792
2/2
✓ Branch 0 taken 1023987 times.
✓ Branch 1 taken 198925 times.
1222912 if (!ok) break;
4793 1023987 }
4794
2/2
✓ Branch 0 taken 1023070 times.
✓ Branch 1 taken 198925 times.
1221995 if(!ok) break;
4795
1/2
✓ Branch 0 taken 1023070 times.
✗ Branch 1 not taken.
1023070 if((usehei%16)>0) //Uneven height
4796 {
4797 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4798 }
4799 1023070 break;
4800 }
4801 case 10:
4802 case right:
4803 {
4804 1212911 dx = dx2+s;
4805 1212911 sv = ((isSideViewGravity())?7:0);
4806 1212911 tries = usehei/(offgrid ? 8 : 16);
4807 //Z_eventlog("Trying move RIGHT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4808
2/2
✓ Branch 0 taken 1024814 times.
✓ Branch 1 taken 1213805 times.
2238619 for ( ; tries > 0; --tries )
4809 {
4810
3/4
✓ Branch 0 taken 186744 times.
✓ Branch 1 taken 1027061 times.
✓ Branch 2 taken 1027061 times.
✗ Branch 3 not taken.
1213805 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4811 1213805 try_y += (offgrid ? 8 : 16);
4812
2/2
✓ Branch 0 taken 1025708 times.
✓ Branch 1 taken 188097 times.
1213805 if (!ok) break;
4813 1025708 }
4814
2/2
✓ Branch 0 taken 1024814 times.
✓ Branch 1 taken 188097 times.
1212911 if(!ok) break;
4815
1/2
✓ Branch 0 taken 1024814 times.
✗ Branch 1 not taken.
1024814 if((usehei%16)>0) //Uneven height
4816 {
4817 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4818 }
4819 1024814 break;
4820 }
4821 case 9:
4822 case r_up:
4823 {
4824 536645 dx = dx2+s;
4825 536645 dy = dy1-s;
4826 536645 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4827 536645 sv = ((isSideViewGravity())?7:0);
4828
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 536645 times.
1056288 for ( ; tries_x > 0; --tries_x )
4829 {
4830 536645 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4831 536645 try_y = 0;
4832
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 536645 times.
1056288 for ( ; tries_y > 0; --tries_y )
4833 {
4834
4/4
✓ Branch 0 taken 528401 times.
✓ Branch 1 taken 8244 times.
✓ Branch 2 taken 522980 times.
✓ Branch 3 taken 5421 times.
1059625 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4835
2/2
✓ Branch 0 taken 2392 times.
✓ Branch 1 taken 520588 times.
522980 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4836 536645 try_y += (offgrid ? 8 : 16);
4837
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 17002 times.
536645 if (!ok) break;
4838 519643 }
4839
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 17002 times.
536645 if (!ok) break;
4840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 519643 times.
519643 if((usehei%16)>0) //Uneven height
4841 {
4842 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4843 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4844 }
4845 519643 try_x += (offgrid ? 8 : 16);
4846 519643 }
4847
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 17002 times.
536645 if(!ok) break;
4848
1/2
✓ Branch 0 taken 519643 times.
✗ Branch 1 not taken.
519643 if((usewid%16)>0) //Uneven width
4849 {
4850 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4851 try_y = 0;
4852 for ( ; tries_y > 0; --tries_y )
4853 {
4854 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4855 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4856 try_y += (offgrid ? 8 : 16);
4857 if (!ok) break;
4858 }
4859 if (!ok) break;
4860 if((usehei%16)>0) //Uneven height
4861 {
4862 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4863 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4864 }
4865 }
4866 519643 break;
4867 }
4868 case 11:
4869 case r_down:
4870 {
4871 638123 dx = dx2+s;
4872 638123 dx = dy2+s;
4873 638123 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4874 //sv = ((isSideViewGravity())?7:0);
4875
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 638123 times.
1260896 for ( ; tries_x > 0; --tries_x )
4876 {
4877 638123 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4878 638123 try_y = 0;
4879
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 638123 times.
1260896 for ( ; tries_y > 0; --tries_y )
4880 {
4881
4/4
✓ Branch 0 taken 636612 times.
✓ Branch 1 taken 1511 times.
✓ Branch 2 taken 623840 times.
✓ Branch 3 taken 12772 times.
1261963 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4882
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 623734 times.
623840 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4883 638123 try_y += (offgrid ? 8 : 16);
4884
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 15350 times.
638123 if (!ok) break;
4885 622773 }
4886
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 15350 times.
638123 if (!ok) break;
4887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 622773 times.
622773 if((usehei%16)>0) //Uneven height
4888 {
4889 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4890 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4891 }
4892 622773 try_x += (offgrid ? 8 : 16);
4893 622773 }
4894
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 15350 times.
638123 if(!ok) break;
4895
1/2
✓ Branch 0 taken 622773 times.
✗ Branch 1 not taken.
622773 if((usewid%16)>0) //Uneven width
4896 {
4897 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4898 try_y = 0;
4899 for ( ; tries_y > 0; --tries_y )
4900 {
4901 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4902 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4903 try_y += (offgrid ? 8 : 16);
4904 if (!ok) break;
4905 }
4906 if (!ok) break;
4907 if((usehei%16)>0) //Uneven height
4908 {
4909 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4910 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4911 }
4912 }
4913 622773 break;
4914 }
4915 case 13:
4916 case l_down:
4917 {
4918 600184 dx = dx1-s;
4919 600184 dy = dy2+s;
4920 600184 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4921 //sv = ((isSideViewGravity())?7:0);
4922
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 600184 times.
1183330 for ( ; tries_x > 0; --tries_x )
4923 {
4924 600184 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4925 600184 try_y = 0;
4926
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 600184 times.
1183330 for ( ; tries_y > 0; --tries_y )
4927 {
4928
4/4
✓ Branch 0 taken 588277 times.
✓ Branch 1 taken 11907 times.
✓ Branch 2 taken 584012 times.
✓ Branch 3 taken 4265 times.
1184196 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4929
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 583444 times.
584012 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4930 600184 try_y += (offgrid ? 8 : 16);
4931
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 17038 times.
600184 if (!ok) break;
4932 583146 }
4933
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 17038 times.
600184 if (!ok) break;
4934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 583146 times.
583146 if((usehei%16)>0) //Uneven height
4935 {
4936 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4937 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4938 }
4939 583146 try_x += (offgrid ? 8 : 16);
4940 583146 }
4941
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 17038 times.
600184 if(!ok) break;
4942
1/2
✓ Branch 0 taken 583146 times.
✗ Branch 1 not taken.
583146 if((usewid%16)>0) //Uneven width
4943 {
4944 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4945 try_y = 0;
4946 for ( ; tries_y > 0; --tries_y )
4947 {
4948 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4949 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4950 try_y += (offgrid ? 8 : 16);
4951 if (!ok) break;
4952 }
4953 if (!ok) break;
4954 if((usehei%16)>0) //Uneven height
4955 {
4956 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4957 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4958 }
4959 }
4960 583146 break;
4961 }
4962 case 15:
4963 case l_up:
4964 {
4965 564898 dx = dx1-s;
4966 564898 dy = dy1-s;
4967 564898 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4968 564898 sv = ((isSideViewGravity())?7:0);
4969
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 564898 times.
1113902 for ( ; tries_x > 0; --tries_x )
4970 {
4971 564898 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4972 564898 try_y = 0;
4973
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 564898 times.
1113902 for ( ; tries_y > 0; --tries_y )
4974 {
4975
4/4
✓ Branch 0 taken 556265 times.
✓ Branch 1 taken 8633 times.
✓ Branch 2 taken 552308 times.
✓ Branch 3 taken 3957 times.
1117206 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4976
2/2
✓ Branch 0 taken 2439 times.
✓ Branch 1 taken 549869 times.
552308 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4977 564898 try_y += (offgrid ? 8 : 16);
4978
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 15894 times.
564898 if (!ok) break;
4979 549004 }
4980
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 15894 times.
564898 if (!ok) break;
4981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 549004 times.
549004 if((usehei%16)>0) //Uneven height
4982 {
4983 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4984 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4985 }
4986 549004 try_x += (offgrid ? 8 : 16);
4987 549004 }
4988
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 15894 times.
564898 if(!ok) break;
4989
1/2
✓ Branch 0 taken 549004 times.
✗ Branch 1 not taken.
549004 if((usewid%16)>0) //Uneven width
4990 {
4991 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4992 try_y = 0;
4993 for ( ; tries_y > 0; --tries_y )
4994 {
4995 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4996 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4997 try_y += (offgrid ? 8 : 16);
4998 if (!ok) break;
4999 }
5000 if (!ok) break;
5001 if((usehei%16)>0) //Uneven height
5002 {
5003 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
5004 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
5005 }
5006 }
5007 549004 break;
5008 }
5009 default:
5010 119653 db=99;
5011 119653 return true;
5012 }
5013 //Z_eventlog("\n");
5014 7204268 return ok;
5015 7325199 }
5016
5017
5018 4624263 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
5019 {
5020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4624263 times.
4624263 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
5021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4624263 times.
4624263 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5022
1/2
✓ Branch 0 taken 4624263 times.
✗ Branch 1 not taken.
4624263 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5023
1/2
✓ Branch 0 taken 4624263 times.
✗ Branch 1 not taken.
4624263 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5024 4624263 --usewid;
5025 4624263 --usehei;
5026 4624263 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
5027 }
5028
5029 1243156 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
5030 {
5031 1243156 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
5032
5033
4/4
✓ Branch 0 taken 6819 times.
✓ Branch 1 taken 1236337 times.
✓ Branch 2 taken 5021 times.
✓ Branch 3 taken 1798 times.
1243156 if(special==spw_clipright&&ndir==right)
5034 {
5035 1798 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
5036 1798 }
5037
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1243151 times.
1243156 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
5038
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1243151 times.
1243156 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5039
1/2
✓ Branch 0 taken 1243156 times.
✗ Branch 1 not taken.
1243156 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5040
1/2
✓ Branch 0 taken 1243156 times.
✗ Branch 1 not taken.
1243156 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5041 1243156 --usewid;
5042 1243156 --usehei;
5043
2/2
✓ Branch 0 taken 716881 times.
✓ Branch 1 taken 526275 times.
1243156 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
5044 }
5045
5046 136202 bool enemy::canmove(int32_t ndir, bool kb)
5047 {
5048 136202 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5049 }
5050
5051 // 8-directional
5052 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5053 {
5054 562 int32_t ndir=0;
5055
5056 // can move straight, check if it wants to turn
5057
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 13 times.
562 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5058 {
5059
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5060 {
5061 int32_t w = Lwpns.idFirst(wBait);
5062
5063 if(w>=0)
5064 {
5065 int32_t bx = Lwpns.spr(w)->x;
5066 int32_t by = Lwpns.spr(w)->y;
5067
5068 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5069
5070 if(abs(int32_t(y)-by)>14)
5071 {
5072 if(ndir>0) // Already left or right
5073 {
5074 // Making the diagonal directions
5075 ndir += (by<y) ? 2 : 4;
5076 }
5077 else
5078 {
5079 ndir = (by<y) ? up : down;
5080 }
5081 }
5082
5083 if(canmove(ndir,special,false))
5084 {
5085 dir=ndir;
5086 return;
5087 }
5088 }
5089 }
5090
5091 // Homing added.
5092
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(newhoming && (zc_oldrand()&255)<newhoming)
5093 {
5094 ndir = lined_up(8,true);
5095
5096 if(ndir>=0 && canmove(ndir,special,false))
5097 {
5098 dir=ndir;
5099 }
5100
5101 return;
5102 }
5103
5104 549 int32_t r=zc_oldrand();
5105
5106
2/4
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 549 times.
549 if(newrate>0 && !(r%newrate))
5107 {
5108 549 ndir = ((dir+((r&64)?-1:1))&7)+8;
5109 549 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5110
5111
2/2
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
549 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5112 525 dir=ndir;
5113
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 19 times.
24 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5114 19 dir=ndir2;
5115
5116
3/4
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 525 times.
✗ Branch 3 not taken.
549 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5117 // due to numerous lost fractional components. -L
5118 {
5119 x.doFloor();
5120 y.doFloor();
5121 }
5122 549 }
5123
5124 549 return;
5125 }
5126
5127 // can't move straight, must turn
5128 13 int32_t i=0;
5129
5130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 for(; i<32; i++) // Try random dir
5131 {
5132 20 ndir=(zc_oldrand()&7)+8;
5133
5134
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13 times.
20 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5135 13 break;
5136 7 }
5137
5138
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(i==32)
5139 {
5140 for(ndir=8; ndir<16; ndir++)
5141 {
5142 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5143 goto ok;
5144 }
5145
5146 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5147 }
5148
5149 ok:
5150 13 dir=ndir;
5151 13 x.doFloor();
5152 13 y.doFloor();
5153 562 }
5154
5155 577113 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5156 {
5157 577113 int32_t ndir=0;
5158
5159 // can move straight, check if it wants to turn
5160
2/2
✓ Branch 0 taken 544558 times.
✓ Branch 1 taken 32555 times.
577113 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5161 {
5162
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 544351 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
544558 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5163 {
5164 101 int32_t i = Lwpns.idFirst(wBait);
5165
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5166 {
5167 weapon *w = (weapon*)Lwpns.spr(i);
5168 if (get_qr(qr_FIND_CLOSEST_BAIT))
5169 {
5170 int32_t currentrange;
5171 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5172 else currentrange = -1;
5173 int curid = i;
5174 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5175 for(; i<Lwpns.Count(); ++i)
5176 {
5177 weapon *lw = (weapon*)Lwpns.spr(i);
5178 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5179 {
5180 currentrange = distance(x, y, lw->x, lw->y);
5181 curid = i;
5182 }
5183 }
5184 i = curid;
5185 if (currentrange == -1) i = -1;
5186 }
5187 else
5188 {
5189 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5190 }
5191 if(i>=0)
5192 {
5193 int32_t bx = Lwpns.spr(i)->x;
5194 int32_t by = Lwpns.spr(i)->y;
5195
5196 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5197
5198 if(abs(int32_t(y)-by)>14)
5199 {
5200 if(ndir>0) // Already left or right
5201 {
5202 // Making the diagonal directions
5203 ndir += (by<y) ? 2 : 4;
5204 }
5205 else
5206 {
5207 ndir = (by<y) ? up : down;
5208 }
5209 }
5210 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5211 if(canmove(ndir,special,false))
5212 {
5213 dir=ndir;
5214 return;
5215 }
5216 }
5217 }
5218 101 }
5219
5220 // Homing added.
5221
4/4
✓ Branch 0 taken 29626 times.
✓ Branch 1 taken 514932 times.
✓ Branch 2 taken 15410 times.
✓ Branch 3 taken 14216 times.
544558 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5222 {
5223 14216 ndir = lined_up(8,true);
5224
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14216 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14216 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5225
4/4
✓ Branch 0 taken 9445 times.
✓ Branch 1 taken 4771 times.
✓ Branch 2 taken 3593 times.
✓ Branch 3 taken 5852 times.
14216 if(ndir>=0 && canmove(ndir,special,false))
5226 {
5227 5852 dir=ndir;
5228 5852 }
5229
5230 14216 return;
5231 }
5232
5233 530342 int32_t r=zc_oldrand();
5234
5235
4/4
✓ Branch 0 taken 338430 times.
✓ Branch 1 taken 191912 times.
✓ Branch 2 taken 178921 times.
✓ Branch 3 taken 159509 times.
530342 if(newrate>0 && !(r%newrate))
5236 {
5237 159509 ndir = ((dir+((r&64)?-1:1))&7)+8;
5238 159509 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5239
5240
2/2
✓ Branch 0 taken 153722 times.
✓ Branch 1 taken 5787 times.
159509 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5241 153722 dir=ndir;
5242
2/2
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 4930 times.
5787 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5243 4930 dir=ndir2;
5244
5245
4/4
✓ Branch 0 taken 153722 times.
✓ Branch 1 taken 5787 times.
✓ Branch 2 taken 146396 times.
✓ Branch 3 taken 7326 times.
159509 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5246 // due to numerous lost fractional components. -L
5247 {
5248 7326 x.doFloor();
5249 7326 y.doFloor();
5250 7326 }
5251 159509 }
5252
5253 530342 return;
5254 }
5255
5256 // can't move straight, must turn
5257 32555 int32_t i=0;
5258
5259
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 60993 times.
61063 for(; i<32; i++) // Try random dir
5260 {
5261 60993 ndir=(zc_oldrand()&7)+8;
5262
5263
2/2
✓ Branch 0 taken 28508 times.
✓ Branch 1 taken 32485 times.
60993 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5264 32485 break;
5265 28508 }
5266
5267
2/2
✓ Branch 0 taken 32485 times.
✓ Branch 1 taken 70 times.
32608 if(i==32)
5268 {
5269
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 53 times.
514 for(ndir=8; ndir<16; ndir++)
5270 {
5271
2/2
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 17 times.
461 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5272 17 goto ok;
5273 444 }
5274
5275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5276 53 }
5277
5278 ok:
5279 32555 dir=ndir;
5280 32555 x.doFloor();
5281 32555 y.doFloor();
5282 577113 }
5283
5284 570638 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5285 {
5286 570638 newdir_8(newrate,newhoming,special,0,-8,15,15);
5287 570638 }
5288
5289 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5290 {
5291 562 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5292 562 }
5293
5294 // makes the enemy slide backwards when hit
5295 // sclk: first byte is clk, second byte is dir
5296 // makes the enemy slide backwards when hit
5297 // sclk: first byte is clk, second byte is dir
5298 15623459 int32_t enemy::slide()
5299 {
5300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15623459 times.
15623459 if(script_knockback_clk!=0) //scripted knockback
5301 {
5302 sclk = 0;
5303 return 1; //scripted knockback ran
5304 }
5305
5/6
✓ Branch 0 taken 102071 times.
✓ Branch 1 taken 15521388 times.
✓ Branch 2 taken 7848 times.
✓ Branch 3 taken 94223 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7848 times.
15623459 if(sclk==0 || (hp<=0 && !immortal))
5306 15529236 return 0;
5307
5308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94223 times.
94223 if(knockbackflags & FLAG_NOSLIDE)
5309 {
5310 sclk = 0;
5311 if(!OFFGRID_ENEMY)
5312 {
5313 //Fix to grid
5314 //x = (int32_t(x)+8)-((int32_t(x)+8)%16);
5315 //y = (int32_t(y)+8)-((int32_t(y)+8)%16);
5316 do_fix(x, 16, true);
5317 do_fix(y, 16, true);
5318 }
5319 return 0;
5320 }
5321
8/10
✓ Branch 0 taken 9551 times.
✓ Branch 1 taken 84672 times.
✓ Branch 2 taken 296 times.
✓ Branch 3 taken 9255 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 296 times.
✓ Branch 6 taken 7103 times.
✓ Branch 7 taken 2152 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 296 times.
94223 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5322 {
5323 2152 sclk=0;
5324 2152 return 0;
5325 }
5326
5327 92071 --sclk;
5328
5329
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10539 times.
✓ Branch 2 taken 12291 times.
✓ Branch 3 taken 31734 times.
✓ Branch 4 taken 35722 times.
92071 switch(sclk>>8)
5330 {
5331 case up:
5332 {
5333
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9449 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 10532 times.
10539 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5334 {
5335 7 sclk=0;
5336 7 return 0;
5337 }
5338
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9442 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 175 times.
10532 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5339
5340 10357 break;
5341 }
5342 case down:
5343 {
5344
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12289 times.
12291 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5345 {
5346 2 sclk=0;
5347 2 return 0;
5348 }
5349
4/4
✓ Branch 0 taken 1069 times.
✓ Branch 1 taken 11220 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 146 times.
12289 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5350
5351 12143 break;
5352 }
5353 case left:
5354 {
5355
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29380 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 31721 times.
31734 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5356 {
5357 13 sclk=0;
5358 13 return 0;
5359 }
5360
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29367 times.
✓ Branch 2 taken 2116 times.
✓ Branch 3 taken 238 times.
31721 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5361
5362 31483 break;
5363 }
5364 case right:
5365 {
5366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35722 times.
35722 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5367 {
5368 sclk=0;
5369 return 0;
5370 }
5371
4/4
✓ Branch 0 taken 3288 times.
✓ Branch 1 taken 32434 times.
✓ Branch 2 taken 3018 times.
✓ Branch 3 taken 270 times.
35722 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5372 35452 break;
5373 }
5374 }
5375
5376 91220 int32_t move = knockbackSpeed;
5377
2/2
✓ Branch 0 taken 86337 times.
✓ Branch 1 taken 91220 times.
177557 while(move>0)
5378 {
5379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91220 times.
91220 int32_t thismove = zc_min(8, move);
5380 91220 move -= thismove;
5381 91220 hitdir = (sclk>>8);
5382
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10357 times.
✓ Branch 2 taken 12143 times.
✓ Branch 3 taken 31483 times.
✓ Branch 4 taken 35452 times.
91220 switch(sclk>>8)
5383 {
5384 case up:
5385 10357 y-=thismove;
5386 10357 break;
5387
5388 case down:
5389 12143 y+=thismove;
5390 12143 break;
5391
5392 case left:
5393 31483 x-=thismove;
5394 31483 break;
5395
5396 case right:
5397 35452 x+=thismove;
5398 35452 break;
5399 }
5400
2/2
✓ Branch 0 taken 86337 times.
✓ Branch 1 taken 4883 times.
91220 if(!canmove(sclk>>8,(zfix)0,0,true))
5401 {
5402
3/3
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 2906 times.
✓ Branch 2 taken 4 times.
4883 switch(sclk>>8)
5403 {
5404 case up:
5405 case down:
5406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973 times.
1973 if(y < 0)
5407 y = 0;
5408
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 1648 times.
1973 else if((int32_t(y)&15) > 7)
5409 325 y=(int32_t(y)&0xF0)+16;
5410 else
5411 1648 y=(int32_t(y)&0xF0);
5412
5413 1973 break;
5414
5415 case left:
5416 case right:
5417
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2902 times.
2906 if(x < 0)
5418 4 x = 0;
5419
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 2069 times.
2902 else if((int32_t(x)&15) > 7)
5420 833 x=(int32_t(x)&0xF0)+16;
5421 else
5422 2069 x=(int32_t(x)&0xF0);
5423
5424 2906 break;
5425 }
5426
5427 4883 sclk=0;
5428 4883 clk3=0;
5429 4883 break;
5430 }
5431 }
5432
5433
2/2
✓ Branch 0 taken 83859 times.
✓ Branch 1 taken 7361 times.
91220 if((sclk&255)==0)
5434 {
5435 //hitdir = -1;
5436 7361 sclk=0;
5437 7361 }
5438 91220 return 2;
5439 15623459 }
5440
5441 bool enemy::can_slide()
5442 {
5443 if(sclk==0 || (hp<=0 && !immortal))
5444 return false;
5445
5446 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5447 {
5448 return false;
5449 }
5450
5451 return true;
5452 }
5453
5454 bool enemy::fslide()
5455 {
5456 if(sclk==0 || (hp<=0 && !immortal))
5457 return false;
5458
5459 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5460 {
5461 sclk=0;
5462 return false;
5463 }
5464
5465 --sclk;
5466
5467 switch(sclk>>8)
5468 {
5469 case up:
5470 if(y<=16)
5471 {
5472 sclk=0;
5473 return false;
5474 }
5475
5476 break;
5477
5478 case down:
5479 if(y>=160)
5480 {
5481 sclk=0;
5482 return false;
5483 }
5484
5485 break;
5486
5487 case left:
5488 if(x<=16)
5489 {
5490 sclk=0;
5491 return false;
5492 }
5493
5494 break;
5495
5496 case right:
5497 if(x>=240)
5498 {
5499 sclk=0;
5500 return false;
5501 }
5502
5503 break;
5504 }
5505 hitdir = (sclk>>8);
5506 switch(sclk>>8)
5507 {
5508 case up:
5509 y-=4;
5510 break;
5511
5512 case down:
5513 y+=4;
5514 break;
5515
5516 case left:
5517 x-=4;
5518 break;
5519
5520 case right:
5521 x+=4;
5522 break;
5523 }
5524
5525 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5526 {
5527 switch(sclk>>8)
5528 {
5529 case up:
5530 case down:
5531 if((int32_t(y)&15) > 7)
5532 y=(int32_t(y)&0xF0)+16;
5533 else
5534 y=(int32_t(y)&0xF0);
5535
5536 break;
5537
5538 case left:
5539 case right:
5540 if((int32_t(x)&15) > 7)
5541 x=(int32_t(x)&0xF0)+16;
5542 else
5543 x=(int32_t(x)&0xF0);
5544
5545 break;
5546 }
5547
5548 sclk=0;
5549 clk3=0;
5550 }
5551
5552 if((sclk&255)==0)
5553 sclk=0;
5554
5555 return true;
5556 }
5557
5558 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5559 {
5560 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5561 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5562 bool ret = sprite::knockback(time, dir, speed);
5563 if(ret) sclk = 0; //kill engine knockback if interrupted
5564 //! Perhaps also set hitdir here, if needed for timing? -Z
5565 return ret;
5566 }
5567
5568 37821661 bool enemy::runKnockback()
5569 {
5570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37821661 times.
37821661 if((script_knockback_clk&0xFF)==0)
5571 {
5572 37821661 script_knockback_clk = 0;
5573 37821661 return false;
5574 }
5575 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5576 {
5577 return false;
5578 }
5579 int32_t move = script_knockback_speed;
5580 int32_t kb_dir = script_knockback_clk>>8;
5581 --script_knockback_clk;
5582
5583 while(move>0)
5584 {
5585 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5586 move -= thismove;
5587 hitdir = kb_dir;
5588 switch(kb_dir)
5589 {
5590 case r_up:
5591 case l_up:
5592 case up:
5593 y-=thismove;
5594 break;
5595
5596 case r_down:
5597 case l_down:
5598 case down:
5599 y+=thismove;
5600 break;
5601 }
5602 switch(kb_dir)
5603 {
5604 case l_up:
5605 case l_down:
5606 case left:
5607 x-=thismove;
5608 break;
5609
5610 case r_up:
5611 case r_down:
5612 case right:
5613 x+=thismove;
5614 break;
5615 }
5616 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5617 {
5618 if(!canmove(kb_dir,(zfix)0,0,true))
5619 {
5620 script_knockback_clk=0;
5621 clk3=0;
5622 //Fix to grid
5623 switch(kb_dir)
5624 {
5625 case up:
5626 case down:
5627 break;
5628 default:
5629 if(x < 0)
5630 x = 0;
5631 else if((int32_t(x)&15) > 7)
5632 x=(int32_t(x)&0xF0)+16;
5633 else
5634 x=(int32_t(x)&0xF0);
5635 break;
5636 }
5637 switch(kb_dir)
5638 {
5639 case left:
5640 case right:
5641 break;
5642 default:
5643 if(y < 0)
5644 y = 0;
5645 else if((int32_t(y)&15) > 7)
5646 y=(int32_t(y)&0xF0)+16;
5647 else
5648 y=(int32_t(y)&0xF0);
5649 break;
5650 }
5651 break;
5652 }
5653 }
5654 else
5655 {
5656 if(!scr_canplace(x,y,0,true))
5657 {
5658 script_knockback_clk=0;
5659 clk3=0;
5660 //Fix to grid
5661 if (OFFGRID_ENEMY)
5662 {
5663 switch(kb_dir)
5664 {
5665 case up:
5666 case down:
5667 break;
5668 default:
5669 if(x < 0)
5670 x = 0;
5671 else if((int32_t(x)&7) > 3)
5672 x=(int32_t(x)&0xF8)+8;
5673 else
5674 x=(int32_t(x)&0xF8);
5675 break;
5676 }
5677 switch(kb_dir)
5678 {
5679 case left:
5680 case right:
5681 break;
5682 default:
5683 if(y < 0)
5684 y = 0;
5685 else if((int32_t(y)&7) > 3)
5686 y=(int32_t(y)&0xF8)+8;
5687 else
5688 y=(int32_t(y)&0xF8);
5689 break;
5690 }
5691 }
5692 else
5693 {
5694 switch(kb_dir)
5695 {
5696 case up:
5697 case down:
5698 break;
5699 default:
5700 if(x < 0)
5701 x = 0;
5702 else if((int32_t(x)&15) > 7)
5703 x=(int32_t(x)&0xF0)+16;
5704 else
5705 x=(int32_t(x)&0xF0);
5706 break;
5707 }
5708 switch(kb_dir)
5709 {
5710 case left:
5711 case right:
5712 break;
5713 default:
5714 if(y < 0)
5715 y = 0;
5716 else if((int32_t(y)&15) > 7)
5717 y=(int32_t(y)&0xF0)+16;
5718 else
5719 y=(int32_t(y)&0xF0);
5720 break;
5721 }
5722 }
5723 break;
5724 }
5725
5726 }
5727 }
5728 return true;
5729 37821661 }
5730 // changes enemy's direction, checking restrictions
5731 // rate: 0 = no random changes, 16 = always random change
5732 // homing: 0 = none, 256 = always
5733 // grumble 0 = none, 4 = strongest appetite
5734 520316 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5735 {
5736 520316 int32_t ndir=-1;
5737
5738
4/4
✓ Branch 0 taken 109954 times.
✓ Branch 1 taken 410362 times.
✓ Branch 2 taken 37802 times.
✓ Branch 3 taken 72152 times.
520316 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble)) //yes, I know checking if grumble is equal to if grumble == 0, but the latter makes the intention more clear to less experienced coders who might join.
5739 {
5740 72152 int32_t i = Lwpns.idFirst(wBait);
5741
1/2
✓ Branch 0 taken 72152 times.
✗ Branch 1 not taken.
72152 if(i >= 0) //idfirst returns -1 if it can't find any
5742 {
5743 weapon *w = (weapon*)Lwpns.spr(i);
5744 if (get_qr(qr_FIND_CLOSEST_BAIT))
5745 {
5746 int32_t currentrange;
5747 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5748 else currentrange = -1;
5749 int curid = i;
5750 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5751 for(; i<Lwpns.Count(); ++i)
5752 {
5753 weapon *lw = (weapon*)Lwpns.spr(i);
5754 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5755 {
5756 currentrange = distance(x, y, lw->x, lw->y);
5757 curid = i;
5758 }
5759 }
5760 i = curid;
5761 if (currentrange == -1) i = -1;
5762 }
5763 else
5764 {
5765 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5766 }
5767 if (i >= 0)
5768 {
5769 int32_t bx = Lwpns.spr(i)->x;
5770 int32_t by = Lwpns.spr(i)->y;
5771
5772 if(abs(int32_t(y)-by)>14)
5773 {
5774 ndir = (by<y) ? up : down;
5775 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5776 if(canmove(ndir,special,false))
5777 {
5778 dir=ndir;
5779 return;
5780 }
5781 }
5782
5783 ndir = (bx<x) ? left : right;
5784 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5785 if(canmove(ndir,special,false))
5786 {
5787 dir=ndir;
5788 return;
5789 }
5790 }
5791 }
5792 72152 }
5793
5794
2/2
✓ Branch 0 taken 352448 times.
✓ Branch 1 taken 167868 times.
520316 if((zc_oldrand()&255)<abs(newhoming))
5795 {
5796 167868 ndir = lined_up(8,false);
5797
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 167868 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
167868 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5798
4/4
✓ Branch 0 taken 45336 times.
✓ Branch 1 taken 122532 times.
✓ Branch 2 taken 5715 times.
✓ Branch 3 taken 39621 times.
167868 if(ndir>=0 && canmove(ndir,special,false))
5799 {
5800 39621 dir=ndir;
5801 39621 return;
5802 }
5803 128247 }
5804
5805 480695 int32_t i=0;
5806
5807
2/2
✓ Branch 0 taken 3335 times.
✓ Branch 1 taken 1179456 times.
1182791 for(; i<32; i++)
5808 {
5809 1179456 int32_t r=zc_oldrand();
5810
5811
2/2
✓ Branch 0 taken 344661 times.
✓ Branch 1 taken 834795 times.
1179456 if((r&15)<newrate)
5812 344661 ndir=(r>>4)&3;
5813 else
5814 834795 ndir=dir;
5815
5816
2/2
✓ Branch 0 taken 702096 times.
✓ Branch 1 taken 477360 times.
1179456 if(canmove(ndir,special,false))
5817 477360 break;
5818 702096 }
5819
5820
2/2
✓ Branch 0 taken 477360 times.
✓ Branch 1 taken 3335 times.
481448 if(i==32)
5821 {
5822
2/2
✓ Branch 0 taken 8919 times.
✓ Branch 1 taken 753 times.
9672 for(ndir=0; ndir<4; ndir++)
5823 {
5824
2/2
✓ Branch 0 taken 6337 times.
✓ Branch 1 taken 2582 times.
8919 if(canmove(ndir,special,false))
5825 2582 goto ok;
5826 6337 }
5827
5828
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 693 times.
753 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5829 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5830 753 }
5831
5832 ok:
5833 480695 dir = ndir;
5834 520316 }
5835
5836 2632 void enemy::newdir()
5837 {
5838 2632 newdir(4,0,spw_none);
5839 2632 }
5840
5841 zfix enemy::distance_left()
5842 {
5843 int32_t a2=x.getInt();
5844 int32_t b2=y.getInt();
5845
5846 switch(dir)
5847 {
5848 case up:
5849 return (zfix)(b2&0xF);
5850
5851 case down:
5852 return (zfix)(16-(b2&0xF));
5853
5854 case left:
5855 return (zfix)(a2&0xF);
5856
5857 case right:
5858 return (zfix)(16-(a2&0xF));
5859 }
5860
5861 return (zfix)0;
5862 }
5863
5864 // keeps walking around
5865 391434 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5866 {
5867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 391434 times.
391434 if(slide())
5868 return;
5869
5870
8/12
✓ Branch 0 taken 387600 times.
✓ Branch 1 taken 3834 times.
✓ Branch 2 taken 387600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 383173 times.
✓ Branch 5 taken 4427 times.
✓ Branch 6 taken 383173 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 383173 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 383173 times.
391434 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5871 8261 return;
5872
5873
2/2
✓ Branch 0 taken 26115 times.
✓ Branch 1 taken 357058 times.
383173 if(clk3<=0)
5874 {
5875 26115 fix_coords(true);
5876 26115 newdir(newrate,newhoming,special);
5877
5878
1/2
✓ Branch 0 taken 26115 times.
✗ Branch 1 not taken.
26115 if(step==0)
5879 clk3=0;
5880 else
5881 26115 clk3=int32_t(16.0/step);
5882 26115 }
5883
2/2
✓ Branch 0 taken 357013 times.
✓ Branch 1 taken 45 times.
357058 else if(scored)
5884 {
5885 45 dir^=1;
5886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5887 else clk3=32767;
5888 45 }
5889
5890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383173 times.
383173 if (step != 0) --clk3;
5891 383173 move(step);
5892 391434 }
5893
5894 void enemy::constant_walk()
5895 {
5896 constant_walk(4,0,spw_none);
5897 }
5898
5899 35220 int32_t enemy::pos(int32_t newx,int32_t newy)
5900 {
5901 35220 return (newy<<8)+newx;
5902 }
5903
5904 // for variable step rates
5905 473814 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5906 {
5907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
473814 if(slide())
5908 return;
5909
5910
10/14
✓ Branch 0 taken 473814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 473814 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 465189 times.
✓ Branch 5 taken 8625 times.
✓ Branch 6 taken 455915 times.
✓ Branch 7 taken 9274 times.
✓ Branch 8 taken 418370 times.
✓ Branch 9 taken 37545 times.
✓ Branch 10 taken 418370 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 418370 times.
✗ Branch 13 not taken.
473814 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5911 55444 return;
5912
5913 418370 zfix dx = (zfix)0;
5914 418370 zfix dy = (zfix)0;
5915
5916
5/9
✓ Branch 0 taken 93441 times.
✓ Branch 1 taken 97752 times.
✓ Branch 2 taken 111603 times.
✓ Branch 3 taken 113743 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1831 times.
418370 switch(dir)
5917 {
5918 case 8:
5919 case up:
5920 93441 dy-=step;
5921 93441 break;
5922
5923 case 12:
5924 case down:
5925 97752 dy+=step;
5926 97752 break;
5927
5928 case 14:
5929 case left:
5930 111603 dx-=step;
5931 111603 break;
5932
5933 case 10:
5934 case right:
5935 113743 dx+=step;
5936 113743 break;
5937
5938 case 15:
5939 case l_up:
5940 dx-=step;
5941 dy-=step;
5942 break;
5943
5944 case 9:
5945 case r_up:
5946 dx+=step;
5947 dy-=step;
5948 break;
5949
5950 case 13:
5951 case l_down:
5952 dx-=step;
5953 dy+=step;
5954 break;
5955
5956 case 11:
5957 case r_down:
5958 dx+=step;
5959 dy+=step;
5960 break;
5961 }
5962
5963
8/8
✓ Branch 0 taken 204198 times.
✓ Branch 1 taken 214172 times.
✓ Branch 2 taken 22777 times.
✓ Branch 3 taken 181421 times.
✓ Branch 4 taken 11556 times.
✓ Branch 5 taken 11221 times.
✓ Branch 6 taken 405927 times.
✓ Branch 7 taken 12443 times.
418370 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5964 406814 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5965 {
5966 12443 fix_coords();
5967 12443 newdir(newrate,newhoming,special);
5968 12443 clk3=pos(x,y);
5969 12443 }
5970
5971 418370 move(step);
5972 473814 }
5973
5974 // pauses for a while after it makes a complete move (to a new square)
5975 12314680 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5976 {
5977
4/4
✓ Branch 0 taken 79858 times.
✓ Branch 1 taken 12234822 times.
✓ Branch 2 taken 67026 times.
✓ Branch 3 taken 12832 times.
12314680 if(sclk && clk2)
5978 {
5979 12832 clk3=0;
5980 12832 }
5981
5982
11/14
✓ Branch 0 taken 12241688 times.
✓ Branch 1 taken 72992 times.
✓ Branch 2 taken 12241688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12241688 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11774520 times.
✓ Branch 7 taken 467168 times.
✓ Branch 8 taken 11636771 times.
✓ Branch 9 taken 137749 times.
✓ Branch 10 taken 11633563 times.
✓ Branch 11 taken 3208 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 11633563 times.
12314680 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5983 {
5984 681117 return;
5985 }
5986
5987
2/2
✓ Branch 0 taken 2132459 times.
✓ Branch 1 taken 9501104 times.
11633563 if(clk2>0)
5988 {
5989 2132459 --clk2;
5990 2132459 return;
5991 }
5992
5993
2/2
✓ Branch 0 taken 410610 times.
✓ Branch 1 taken 9090494 times.
9501104 if(clk3<=0)
5994 {
5995 410610 fix_coords(true);
5996 410610 newdir(newrate,newhoming,special);
5997 410610 clk3=int32_t(16.0/step);
5998
2/2
✓ Branch 0 taken 410415 times.
✓ Branch 1 taken 195 times.
410610 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410610 times.
410610 if(clk2<0)
6000 {
6001 clk2=0;
6002 }
6003
2/2
✓ Branch 0 taken 54758 times.
✓ Branch 1 taken 355852 times.
410610 else if((zc_oldrand()&15)<newhrate)
6004 {
6005 54758 clk2=haltcnt;
6006 54758 return;
6007 }
6008 355852 }
6009
2/2
✓ Branch 0 taken 9087335 times.
✓ Branch 1 taken 3159 times.
9090494 else if(scored)
6010 {
6011 3159 dir^=1;
6012
6013
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3154 times.
3159 if (step != 0) clk3=int32_t(16.0/step)-clk3;
6014 5 else clk3=32767;
6015 3159 }
6016
6017
2/2
✓ Branch 0 taken 74649 times.
✓ Branch 1 taken 9371697 times.
9446346 if (step != 0) --clk3;
6018 9446346 move(step);
6019 12314680 }
6020
6021 // 8-directional movement, aligns to 8 pixels
6022 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
6023 {
6024 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6025 return;
6026
6027 if(clk3<=0)
6028 {
6029 newdir_8(newrate,newhoming,special);
6030 clk3=int32_t(8.0/step);
6031 if (step == 0) clk3 = 32767;
6032 }
6033
6034 if (step != 0) --clk3;
6035 move(step);
6036 }
6037 // 8-directional movement, aligns to 8 pixels
6038 242393 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
6039 {
6040
6/12
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242393 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 242393 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 242393 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 242393 times.
242393 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6041 return;
6042
6043
2/2
✓ Branch 0 taken 226158 times.
✓ Branch 1 taken 16235 times.
242393 if(clk3<=0)
6044 {
6045 16235 newdir_8(newrate,newhoming,special);
6046 16235 clk3=int32_t(8.0/step);
6047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16235 times.
16235 if (step == 0) clk3 = 32767;
6048 16235 }
6049
6050
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if (step != 0) --clk3;
6051 242393 move(step);
6052 242393 }
6053
6054 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6055 {
6056 if(clk<0 || dying || stunclk || watch || frozenclock)
6057 return;
6058
6059 if(!canmove(dir,step,special,false))
6060 clk3=0;
6061
6062 if(clk2>0)
6063 {
6064 --clk2;
6065 return;
6066 }
6067
6068 if(clk3<=0)
6069 {
6070 newdir_8(newrate,newhoming,special);
6071 clk3=newclk;
6072
6073 if(clk2<0)
6074 {
6075 clk2=0;
6076 }
6077 else if((zc_oldrand()&15)<newhrate)
6078 {
6079 newdir_8(newrate,newhoming,special);
6080 clk2=haltcnt;
6081 return;
6082 }
6083 }
6084
6085 --clk3;
6086 move(step);
6087 }
6088
6089 // 8-directional movement, no alignment
6090 4691075 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6091 {
6092
9/12
✓ Branch 0 taken 4483752 times.
✓ Branch 1 taken 207323 times.
✓ Branch 2 taken 4483752 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4457131 times.
✓ Branch 5 taken 26621 times.
✓ Branch 6 taken 4446084 times.
✓ Branch 7 taken 11047 times.
✓ Branch 8 taken 4446084 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4446084 times.
4691075 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6093 244991 return;
6094
6095
2/2
✓ Branch 0 taken 4415704 times.
✓ Branch 1 taken 30380 times.
4446084 if(!canmove(dir,step,special,false))
6096 30380 clk3=0;
6097
6098
2/2
✓ Branch 0 taken 3891681 times.
✓ Branch 1 taken 554403 times.
4446084 if(clk3<=0)
6099 {
6100 554403 newdir_8(newrate,newhoming,special);
6101 554403 clk3=newclk;
6102 554403 }
6103
6104 4446084 --clk3;
6105 4446084 move(step);
6106 4691075 }
6107
6108 // same as above but with variable enemy size
6109 94563 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6110 {
6111
8/12
✓ Branch 0 taken 93367 times.
✓ Branch 1 taken 1196 times.
✓ Branch 2 taken 93367 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93367 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 93316 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 93316 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 93316 times.
94563 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6112 1247 return;
6113
6114
2/2
✓ Branch 0 taken 91982 times.
✓ Branch 1 taken 1334 times.
93316 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6115 1334 clk3=0;
6116
6117
2/2
✓ Branch 0 taken 86841 times.
✓ Branch 1 taken 6475 times.
93316 if(clk3<=0)
6118 {
6119 6475 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6120 6475 clk3=newclk;
6121 6475 }
6122
6123 93316 --clk3;
6124 93316 move(step);
6125 94563 }
6126
6127 // the variable speed floater movement
6128 // ms is max speed
6129 // ss is step speed
6130 // s is step count
6131 // p is pause count
6132 // g is graduality :)
6133 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6134 3989892 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6135 {
6136 3989892 ++clk2;
6137 3989892 byte over_pit = overpit(this);
6138
6139
4/4
✓ Branch 0 taken 1114794 times.
✓ Branch 1 taken 2875098 times.
✓ Branch 2 taken 1114527 times.
✓ Branch 3 taken 267 times.
3989892 if(dmisc1 && over_pit) p = 0;
6140
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 56213 times.
✓ Branch 2 taken 1570783 times.
✓ Branch 3 taken 2230728 times.
✓ Branch 4 taken 132168 times.
3989892 switch(movestatus)
6141 {
6142 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6143 //! if the conditions prevent it, we jump back to case 2.
6144 case 0: // paused
6145
2/2
✓ Branch 0 taken 54765 times.
✓ Branch 1 taken 1448 times.
56213 if(clk2>=p)
6146 {
6147 1448 movestatus=1;
6148 1448 clk2=0;
6149 1448 }
6150
6151 56213 break;
6152
6153 case 1: // speeding up
6154
1/2
✓ Branch 0 taken 1570783 times.
✗ Branch 1 not taken.
1570783 if (s >= 0)
6155 {
6156
2/2
✓ Branch 0 taken 1559550 times.
✓ Branch 1 taken 11233 times.
1570783 if(clk2<g*s)
6157 {
6158
2/2
✓ Branch 0 taken 1458948 times.
✓ Branch 1 taken 100602 times.
1559550 if(!((clk2-1)%g))
6159 100602 step+=ss;
6160 1559550 }
6161 else
6162 {
6163 11233 movestatus=2;
6164 11233 clk2=0;
6165 }
6166 1570783 }
6167 else
6168 {
6169 if(step < ms)
6170 {
6171 if(!((clk2-1)%g))
6172 {
6173 step+=ss;
6174 if (step >= ms) step = ms;
6175 }
6176 }
6177 else
6178 {
6179 step = ms;
6180 movestatus=2;
6181 clk2=0;
6182 }
6183 }
6184
6185 1570783 break;
6186
6187 case 2: // normal
6188 2230728 step=ms;
6189
6190
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2230728 times.
✓ Branch 2 taken 477682 times.
✓ Branch 3 taken 1753046 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1753046 times.
✓ Branch 6 taken 1750807 times.
✓ Branch 7 taken 2239 times.
2230728 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6191 {
6192
1/2
✓ Branch 0 taken 2239 times.
✗ Branch 1 not taken.
2239 if (s >= 0) step=ss*s;
6193 else step=ms;
6194 2239 movestatus=3;
6195 2239 clk2=0;
6196 2239 }
6197
6198 2230728 break;
6199
6200 case 3: // slowing down
6201
1/2
✓ Branch 0 taken 132168 times.
✗ Branch 1 not taken.
132168 if (s >= 0)
6202 {
6203
2/2
✓ Branch 0 taken 130491 times.
✓ Branch 1 taken 1677 times.
132168 if(clk2<=g*s)
6204 {
6205 { //don't slow down over pits
6206
6207
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 130224 times.
130491 if(over_pit)
6208 {
6209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267 times.
267 if(dmisc1)
6210 {
6211 step=ms;
6212 }
6213 267 }
6214 else //can slow down
6215 {
6216
4/4
✓ Branch 0 taken 8036 times.
✓ Branch 1 taken 122188 times.
✓ Branch 2 taken 7668 times.
✓ Branch 3 taken 368 times.
130224 if(!(clk2%g) && !dmisc1)
6217 7668 step-=ss;
6218 }
6219 }
6220
6221
6222 130491 }
6223 else
6224 {
6225 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6226 //this doesn't help keese, as they have a z of 0.
6227 //they always nee to run this check.
6228 {
6229
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1677 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1677 if(over_pit &&!dmisc1)
6230 {
6231 --clk2; //if over a pit, don't land, and revert clock change
6232 }
6233 else //can land safely
6234 {
6235 1677 movestatus=0;
6236
3/4
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 562 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1115 times.
1677 if(dmisc1&&!over_pit)
6237 1115 step=0;
6238 1677 clk2=0;
6239 }
6240 }
6241
6242 }
6243 132168 }
6244 else
6245 {
6246 if(step > 0)
6247 {
6248 if(over_pit)
6249 {
6250 if(dmisc1)
6251 {
6252 step=ms;
6253 }
6254 }
6255 else //can slow down
6256 {
6257 if(!(clk2%g))
6258 step-=ss;
6259 }
6260 }
6261 else
6262 {
6263 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6264 //this doesn't help keese, as they have a z of 0.
6265 //they always nee to run this check.
6266 if(over_pit)
6267 {
6268 step+=ss; //if over a pit, don't land, and revert clock change
6269 }
6270 else //can land safely
6271 {
6272 movestatus=0;
6273 step=0;
6274 clk2=0;
6275 }
6276 }
6277 }
6278
6279 132168 break;
6280 }
6281
6282
2/2
✓ Branch 0 taken 2239722 times.
✓ Branch 1 taken 1750170 times.
3989892 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6283 3989892 }
6284
6285 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6286 {
6287 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6288 }
6289
6290 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6291 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6292 923644 int32_t enemy::lined_up(int32_t range, bool dir8)
6293 {
6294 923644 int32_t lx = Hero.getX();
6295 923644 int32_t ly = Hero.getY();
6296
6297
2/2
✓ Branch 0 taken 38484 times.
✓ Branch 1 taken 885160 times.
923644 if(abs(lx-int32_t(x))<=range)
6298 {
6299
2/2
✓ Branch 0 taken 16113 times.
✓ Branch 1 taken 22371 times.
38484 if(ly<y)
6300 {
6301 16113 return up;
6302 }
6303
6304 22371 return down;
6305 }
6306
6307
2/2
✓ Branch 0 taken 56299 times.
✓ Branch 1 taken 828861 times.
885160 if(abs(ly-int32_t(y))<=range)
6308 {
6309
2/2
✓ Branch 0 taken 30278 times.
✓ Branch 1 taken 26021 times.
56299 if(lx<x)
6310 {
6311 30278 return left;
6312 }
6313
6314 26021 return right;
6315 }
6316
6317
2/2
✓ Branch 0 taken 159811 times.
✓ Branch 1 taken 669050 times.
828861 if(dir8)
6318 {
6319
2/2
✓ Branch 0 taken 252160 times.
✓ Branch 1 taken 416890 times.
669050 if(abs(lx-x)-abs(ly-y)<=range)
6320 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6321 {
6322
2/2
✓ Branch 0 taken 105160 times.
✓ Branch 1 taken 147000 times.
252160 if(ly<y)
6323 {
6324
2/2
✓ Branch 0 taken 56622 times.
✓ Branch 1 taken 48538 times.
105160 if(lx<x)
6325 {
6326 56622 return l_up;
6327 }
6328 else
6329 {
6330 48538 return r_up;
6331 }
6332 }
6333 else
6334 {
6335
2/2
✓ Branch 0 taken 76220 times.
✓ Branch 1 taken 70780 times.
147000 if(lx<x)
6336 {
6337 70780 return l_down;
6338 }
6339 else
6340 {
6341 76220 return r_down;
6342 }
6343 }
6344 }
6345 416890 }
6346
6347 576701 return -1;
6348 923644 }
6349
6350 // returns true if Hero is within 'range' pixels of the enemy
6351 27884 bool enemy::HeroInRange(int32_t range)
6352 {
6353 27884 int32_t lx = Hero.getX();
6354 27884 int32_t ly = Hero.getY();
6355
2/2
✓ Branch 0 taken 22775 times.
✓ Branch 1 taken 5109 times.
27884 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6356 }
6357
6358 // place the enemy in line with Hero (red wizzrobes)
6359 4858 void enemy::place_on_axis(bool floater, bool solid_ok)
6360 {
6361
6/6
✓ Branch 0 taken 573 times.
✓ Branch 1 taken 4285 times.
✓ Branch 2 taken 4316 times.
✓ Branch 3 taken 542 times.
✓ Branch 4 taken 573 times.
✓ Branch 5 taken 3743 times.
4858 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6362
6/6
✓ Branch 0 taken 437 times.
✓ Branch 1 taken 4421 times.
✓ Branch 2 taken 4082 times.
✓ Branch 3 taken 776 times.
✓ Branch 4 taken 437 times.
✓ Branch 5 taken 3645 times.
4858 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6363 4858 int32_t pos2=zc_oldrand()%23;
6364 4858 int32_t tried=0;
6365 4858 bool last_resort,placed=false;
6366
6367
6368 4858 do
6369 {
6370
2/2
✓ Branch 0 taken 4432 times.
✓ Branch 1 taken 3104 times.
7536 if(pos2<14)
6371 {
6372 4432 x=(pos2<<4)+16;
6373 4432 y=ly;
6374 4432 }
6375 else
6376 {
6377 3104 x=lx;
6378 3104 y=((pos2-14)<<4)+16;
6379 }
6380
6381 // Don't commit to a last resort if position is out of bounds.
6382
6/6
✓ Branch 0 taken 7199 times.
✓ Branch 1 taken 337 times.
✓ Branch 2 taken 6889 times.
✓ Branch 3 taken 310 times.
✓ Branch 4 taken 255 times.
✓ Branch 5 taken 6634 times.
7536 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6383
6384
4/4
✓ Branch 0 taken 3879 times.
✓ Branch 1 taken 3657 times.
✓ Branch 2 taken 4912 times.
✓ Branch 3 taken 1443 times.
7536 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6385 {
6386 // Red Wizzrobes should be able to appear on water, but not other
6387 // solid combos; however, they could appear on solid combos in 2.10,
6388 // and some quests depend on that.
6389
4/4
✓ Branch 0 taken 2341 times.
✓ Branch 1 taken 6228 times.
✓ Branch 2 taken 1370 times.
✓ Branch 3 taken 4858 times.
8569 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6390 8569 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6391 4858 placed=true;
6392 8569 }
6393
6394
3/6
✓ Branch 0 taken 2678 times.
✓ Branch 1 taken 4662 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2678 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7340 if(!placed && tried>=22 && last_resort)
6395 {
6396 placed=true;
6397 }
6398
6399 7340 ++tried;
6400 7340 pos2=(pos2+3)%23;
6401
2/2
✓ Branch 0 taken 2678 times.
✓ Branch 1 taken 4662 times.
7340 }
6402 7340 while(!placed);
6403
6404
2/2
✓ Branch 0 taken 2872 times.
✓ Branch 1 taken 1790 times.
4662 if(y==ly)
6405 2872 dir=(x<lx)?right:left;
6406 else
6407 1790 dir=(y<ly)?down:up;
6408
6409 4662 clk2=tried;
6410 4662 }
6411
6412 20213685 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6413 {
6414 20213685 int32_t t = o_tile;
6415 20213685 int32_t b = o_tile;
6416
6417 // Darknuts, but also Wizzrobes and Wallmasters
6418
3/4
✓ Branch 0 taken 8353120 times.
✓ Branch 1 taken 10837883 times.
✓ Branch 2 taken 1022682 times.
✗ Branch 3 not taken.
20213685 switch(family)
6419 {
6420 case eeWALK:
6421
5/6
✓ Branch 0 taken 505407 times.
✓ Branch 1 taken 10332476 times.
✓ Branch 2 taken 367468 times.
✓ Branch 3 taken 137939 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 367468 times.
10837883 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6422 {
6423 367468 tile=s_tile;
6424 367468 t=s_tile;
6425 367468 b=s_tile;
6426 367468 }
6427
6428 10837883 break;
6429
6430 case eeTRAP:
6431
4/6
✓ Branch 0 taken 193566 times.
✓ Branch 1 taken 829116 times.
✓ Branch 2 taken 193566 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 193566 times.
1022682 if(dummy_int[1] && guysbuf[id].flags & guy_trp2 && do_animation) // Just to make sure
6432 {
6433 193566 tile=s_tile;
6434 193566 t=s_tile;
6435 193566 b=s_tile;
6436 193566 }
6437
6438 1022682 break;
6439
6440 case eeSPINTILE:
6441 if(misc>=96 && do_animation)
6442 {
6443 tile=o_tile+frames*ndir;
6444 t=tile;
6445 }
6446
6447 break;
6448 }
6449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20213685 times.
20213685 if ( do_animation )
6450 {
6451
4/6
✓ Branch 0 taken 197042 times.
✓ Branch 1 taken 20016643 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 267131 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 19749512 times.
20213685 if(ndir!=0) switch(frames)
6452 {
6453 case 2:
6454 267131 tiledir_small(dir,ndir==4);
6455 267131 break;
6456
6457 case 3:
6458 tiledir_three(dir);
6459 break;
6460
6461 case 4:
6462 19749512 tiledir(dir,ndir==4);
6463 19749512 break;
6464 20016643 }
6465
6466
2/2
✓ Branch 0 taken 10837883 times.
✓ Branch 1 taken 9375802 times.
20213685 if(family==eeWALK)
6467
6/6
✓ Branch 0 taken 10776874 times.
✓ Branch 1 taken 61009 times.
✓ Branch 2 taken 8177902 times.
✓ Branch 3 taken 2659981 times.
✓ Branch 4 taken 2644258 times.
✓ Branch 5 taken 15723 times.
10837883 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6468 else
6469 9375802 tile+=f4;
6470 20213685 }
6471 20213685 return b;
6472 }
6473
6474 void enemy::tiledir_three(int32_t ndir)
6475 {
6476 if ( !do_animation ) return;
6477 flip=0;
6478
6479 switch(ndir)
6480 {
6481 case right:
6482 tile+=3;
6483 [[fallthrough]];
6484
6485 case left:
6486 tile+=3;
6487 [[fallthrough]];
6488
6489 case down:
6490 tile+=3;
6491 [[fallthrough]];
6492
6493 case up:
6494 break;
6495 }
6496 }
6497
6498 267131 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6499 {
6500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267131 times.
267131 if ( !do_animation ) return;
6501 267131 flip=0;
6502
6503
8/9
✓ Branch 0 taken 53829 times.
✓ Branch 1 taken 54679 times.
✓ Branch 2 taken 67727 times.
✓ Branch 3 taken 71182 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
267131 switch(ndir)
6504 {
6505 case 8:
6506 case up:
6507 53829 break;
6508
6509 case 12:
6510 case down:
6511 54679 tile+=2;
6512 54679 break;
6513
6514 case 14:
6515 case left:
6516 67727 tile+=4;
6517 67727 break;
6518
6519 case 10:
6520 case right:
6521 71182 tile+=6;
6522 71182 break;
6523
6524 case 9:
6525 case r_up:
6526
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6527 5706 break;
6528
6529 tile+=10;
6530 break;
6531
6532 case 11:
6533 case r_down:
6534
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6535 5154 tile+=2;
6536 else
6537 tile+=14;
6538
6539 5154 break;
6540
6541 case 13:
6542 case l_down:
6543
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6544 4872 tile+=2;
6545 else
6546 tile+=12;
6547
6548 4872 break;
6549
6550 case 15:
6551 case l_up:
6552
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6553 3982 break;
6554
6555 tile+=8;
6556 break;
6557
6558 default:
6559 //dir=(zc_oldrand()*100)%8;
6560 //tiledir_small(dir);
6561 // flip=zc_oldrand()&3;
6562 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6563 break;
6564 }
6565 267131 }
6566
6567 23069632 void enemy::tiledir(int32_t ndir, bool fourdir)
6568 {
6569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23069632 times.
23069632 if ( !do_animation ) return;
6570 23069632 flip=0;
6571
6572
9/9
✓ Branch 0 taken 4483892 times.
✓ Branch 1 taken 4141765 times.
✓ Branch 2 taken 5412757 times.
✓ Branch 3 taken 5175571 times.
✓ Branch 4 taken 825768 times.
✓ Branch 5 taken 1018734 times.
✓ Branch 6 taken 1099241 times.
✓ Branch 7 taken 845055 times.
✓ Branch 8 taken 66849 times.
23069632 switch(ndir)
6573 {
6574 case 8:
6575 case up:
6576 4483892 break;
6577
6578 case 12:
6579 case down:
6580 4141765 tile+=4;
6581 4141765 break;
6582
6583 case 14:
6584 case left:
6585 5412757 tile+=8;
6586 5412757 break;
6587
6588 case 10:
6589 case right:
6590 5175571 tile+=12;
6591 5175571 break;
6592
6593 case 9:
6594 case r_up:
6595
2/2
✓ Branch 0 taken 88653 times.
✓ Branch 1 taken 737115 times.
825768 if(fourdir)
6596 88653 break;
6597 else
6598 737115 tile+=24;
6599
6600 737115 break;
6601
6602 case 11:
6603 case r_down:
6604
2/2
✓ Branch 0 taken 101949 times.
✓ Branch 1 taken 916785 times.
1018734 if(fourdir)
6605 101949 tile+=4;
6606 else
6607 916785 tile+=32;
6608
6609 1018734 break;
6610
6611 case 13:
6612 case l_down:
6613
2/2
✓ Branch 0 taken 105945 times.
✓ Branch 1 taken 993296 times.
1099241 if(fourdir)
6614 105945 tile+=4;
6615 else
6616 993296 tile+=28;
6617
6618 1099241 break;
6619
6620 case 15:
6621 case l_up:
6622
2/2
✓ Branch 0 taken 82760 times.
✓ Branch 1 taken 762295 times.
845055 if(fourdir)
6623 82760 break;
6624 else
6625 762295 tile+=20;
6626
6627 762295 break;
6628
6629 default:
6630 //dir=(zc_oldrand()*100)%8;
6631 //tiledir(dir);
6632 // flip=zc_oldrand()&3;
6633 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6634 66849 break;
6635 }
6636 23069632 }
6637
6638 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6639 {
6640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if ( !do_animation ) return;
6641 3868 flip=0;
6642
6643
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6644 {
6645 case 8:
6646 case up:
6647 297 break;
6648
6649 case 12:
6650 case down:
6651 tile+=8;
6652 break;
6653
6654 case 14:
6655 case left:
6656 195 tile+=40;
6657 195 break;
6658
6659 case 10:
6660 case right:
6661 179 tile+=48;
6662 179 break;
6663
6664 case 9:
6665 case r_up:
6666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6667 break;
6668
6669 306 tile+=88;
6670 306 break;
6671
6672 case 11:
6673 case r_down:
6674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6675 tile+=8;
6676 else
6677 1235 tile+=128;
6678
6679 1235 break;
6680
6681 case 13:
6682 case l_down:
6683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6684 tile+=8;
6685 else
6686 1324 tile+=120;
6687
6688 1324 break;
6689
6690 case 15:
6691 case l_up:
6692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6693 break;
6694
6695 332 tile+=80;
6696 332 break;
6697
6698 default:
6699 //dir=(zc_oldrand()*100)%8;
6700 //tiledir_big(dir);
6701 // flip=zc_oldrand()&3;
6702 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6703 break;
6704 }
6705 3868 }
6706
6707 39891825 void enemy::update_enemy_frame()
6708 {
6709
4/4
✓ Branch 0 taken 39889519 times.
✓ Branch 1 taken 2306 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 39889512 times.
39891825 if(fallclk||drownclk) return;
6710
1/2
✓ Branch 0 taken 39889512 times.
✗ Branch 1 not taken.
39889512 if (!do_animation)
6711 return;
6712
6713
4/4
✓ Branch 0 taken 1474046 times.
✓ Branch 1 taken 38415466 times.
✓ Branch 2 taken 1472039 times.
✓ Branch 3 taken 2007 times.
39889512 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6714
6715
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
39889512 if(get_qr(qr_ANONE_NOANIM)
6716
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 39889512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
39889512 && anim == aNONE && family != eeGUY)
6717 return;
6718
2/2
✓ Branch 0 taken 371376 times.
✓ Branch 1 taken 39518136 times.
39889512 int32_t newfrate = zc_max(frate,4);
6719 39889512 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6720 39889512 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6721
2/2
✓ Branch 0 taken 29898417 times.
✓ Branch 1 taken 9991095 times.
39889512 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6722 39889512 tile = o_tile;
6723 39889512 int32_t basetile = o_tile;
6724 39889512 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6725 39889512 bool ignore_extend = false;
6726
35/40
✓ Branch 0 taken 220021 times.
✓ Branch 1 taken 8628 times.
✓ Branch 2 taken 199337 times.
✓ Branch 3 taken 1755010 times.
✓ Branch 4 taken 363745 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140514 times.
✓ Branch 7 taken 366633 times.
✓ Branch 8 taken 836734 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4981821 times.
✓ Branch 12 taken 69324 times.
✓ Branch 13 taken 53456 times.
✓ Branch 14 taken 38833 times.
✓ Branch 15 taken 455374 times.
✓ Branch 16 taken 1519575 times.
✓ Branch 17 taken 197042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 128880 times.
✓ Branch 20 taken 221637 times.
✓ Branch 21 taken 686882 times.
✓ Branch 22 taken 1690654 times.
✓ Branch 23 taken 1133827 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 267131 times.
✓ Branch 26 taken 4117708 times.
✓ Branch 27 taken 7475916 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 582791 times.
✓ Branch 30 taken 1178979 times.
✓ Branch 31 taken 880176 times.
✓ Branch 32 taken 218668 times.
✓ Branch 33 taken 1812060 times.
✓ Branch 34 taken 133344 times.
✓ Branch 35 taken 1433 times.
✓ Branch 36 taken 6953976 times.
✓ Branch 37 taken 747030 times.
✓ Branch 38 taken 276997 times.
✓ Branch 39 taken 171508 times.
39889512 switch(anim)
6727 {
6728
6729 case aDONGO:
6730 {
6731 69324 int32_t fr = stunclk>0 ? 16 : 8;
6732
6733
6/6
✓ Branch 0 taken 67426 times.
✓ Branch 1 taken 1898 times.
✓ Branch 2 taken 6720 times.
✓ Branch 3 taken 60706 times.
✓ Branch 4 taken 2240 times.
✓ Branch 5 taken 4480 times.
69324 if(!dying && clk2>0 && clk2<=64)
6734 {
6735 // bloated
6736
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 960 times.
✓ Branch 3 taken 1664 times.
✓ Branch 4 taken 896 times.
4480 switch(dir)
6737 {
6738 case up:
6739 960 tile+=9;
6740 960 flip=0;
6741 960 xofs=0;
6742 960 dummy_int[1]=0; //no additional tiles
6743 960 break;
6744
6745 case down:
6746 960 tile+=7;
6747 960 flip=0;
6748 960 xofs=0;
6749 960 dummy_int[1]=0; //no additional tiles
6750 960 break;
6751
6752 case left:
6753 1664 flip=1;
6754 1664 tile+=4;
6755 1664 xofs=16;
6756 1664 dummy_int[1]=1; //second tile is next tile
6757 1664 break;
6758
6759 case right:
6760 896 flip=0;
6761 896 tile+=5;
6762 896 xofs=16;
6763 896 dummy_int[1]=-1; //second tile is previous tile
6764 896 break;
6765 }
6766 4480 }
6767
4/4
✓ Branch 0 taken 1898 times.
✓ Branch 1 taken 62946 times.
✓ Branch 2 taken 781 times.
✓ Branch 3 taken 1117 times.
64844 else if(!dying || clk2>19)
6768 {
6769 // normal
6770
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13652 times.
✓ Branch 2 taken 15374 times.
✓ Branch 3 taken 19615 times.
✓ Branch 4 taken 15086 times.
63727 switch(dir)
6771 {
6772 case up:
6773 13652 tile+=8;
6774 13652 flip=(clk&fr)?1:0;
6775 13652 xofs=0;
6776 13652 dummy_int[1]=0; //no additional tiles
6777 13652 break;
6778
6779 case down:
6780 15374 tile+=6;
6781 15374 flip=(clk&fr)?1:0;
6782 15374 xofs=0;
6783 15374 dummy_int[1]=0; //no additional tiles
6784 15374 break;
6785
6786 case left:
6787 19615 flip=1;
6788 19615 tile+=(clk&fr)?2:0;
6789 19615 xofs=16;
6790 19615 dummy_int[1]=1; //second tile is next tile
6791 19615 break;
6792
6793 case right:
6794 15086 flip=0;
6795 15086 tile+=(clk&fr)?3:1;
6796 15086 xofs=16;
6797 15086 dummy_int[1]=-1; //second tile is next tile
6798 15086 break;
6799 }
6800 63727 }
6801 }
6802 69324 break;
6803
6804 case aNEWDONGO:
6805 {
6806 53456 int32_t fr4=0;
6807
6808
6/6
✓ Branch 0 taken 51564 times.
✓ Branch 1 taken 1892 times.
✓ Branch 2 taken 4128 times.
✓ Branch 3 taken 47436 times.
✓ Branch 4 taken 1376 times.
✓ Branch 5 taken 2752 times.
53456 if(!dying && clk2>0 && clk2<=64)
6809 {
6810 // bloated
6811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2752 times.
2752 if(clk2>=0)
6812 {
6813 2752 fr4=3;
6814 2752 }
6815
6816
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 2107 times.
2752 if(clk2>=16)
6817 {
6818 2107 fr4=2;
6819 2107 }
6820
6821
2/2
✓ Branch 0 taken 1333 times.
✓ Branch 1 taken 1419 times.
2752 if(clk2>=32)
6822 {
6823 1419 fr4=1;
6824 1419 }
6825
6826
2/2
✓ Branch 0 taken 2021 times.
✓ Branch 1 taken 731 times.
2752 if(clk2>=48)
6827 {
6828 731 fr4=0;
6829 731 }
6830
6831
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 1216 times.
2752 switch(dir)
6832 {
6833 case up:
6834 256 xofs=0;
6835 256 tile+=8+fr4;
6836 256 dummy_int[1]=0; //no additional tiles
6837 256 break;
6838
6839 case down:
6840 576 xofs=0;
6841 576 tile+=12+fr4;
6842 576 dummy_int[1]=0; //no additional tiles
6843 576 break;
6844
6845 case left:
6846 704 tile+=29+(2*fr4);
6847 704 xofs=16;
6848 704 dummy_int[1]=-1; //second tile is previous tile
6849 704 break;
6850
6851 case right:
6852 1216 tile+=49+(2*fr4);
6853 1216 xofs=16;
6854 1216 dummy_int[1]=-1; //second tile is previous tile
6855 1216 break;
6856 }
6857 2752 }
6858
4/4
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 48812 times.
✓ Branch 2 taken 994 times.
✓ Branch 3 taken 898 times.
50704 else if(!dying || clk2>19)
6859 {
6860 // normal
6861
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9234 times.
✓ Branch 2 taken 9871 times.
✓ Branch 3 taken 15025 times.
✓ Branch 4 taken 15676 times.
49806 switch(dir)
6862 {
6863 case up:
6864 9234 xofs=0;
6865 9234 tile+=((clk&12)>>2);
6866 9234 dummy_int[1]=0; //no additional tiles
6867 9234 break;
6868
6869 case down:
6870 9871 xofs=0;
6871 9871 tile+=4+((clk&12)>>2);
6872 9871 dummy_int[1]=0; //no additional tiles
6873 9871 break;
6874
6875 case left:
6876 15025 tile+=21+((clk&12)>>1);
6877 15025 xofs=16;
6878 15025 dummy_int[1]=-1; //second tile is previous tile
6879 15025 break;
6880
6881 case right:
6882 15676 flip=0;
6883 15676 tile+=41+((clk&12)>>1);
6884 15676 xofs=16;
6885 15676 dummy_int[1]=-1; //second tile is previous tile
6886 15676 break;
6887 }
6888 49806 }
6889 }
6890 53456 break;
6891
6892 case aDONGOBS:
6893 {
6894 38833 int32_t fr4=0;
6895
6896
6/6
✓ Branch 0 taken 37675 times.
✓ Branch 1 taken 1158 times.
✓ Branch 2 taken 4032 times.
✓ Branch 3 taken 33643 times.
✓ Branch 4 taken 1344 times.
✓ Branch 5 taken 2688 times.
38833 if(!dying && clk2>0 && clk2<=64)
6897 {
6898 // bloated
6899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2688 times.
2688 if(clk2>=0)
6900 {
6901 2688 fr4=3;
6902 2688 }
6903
6904
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 2058 times.
2688 if(clk2>=16)
6905 {
6906 2058 fr4=2;
6907 2058 }
6908
6909
2/2
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 1386 times.
2688 if(clk2>=32)
6910 {
6911 1386 fr4=1;
6912 1386 }
6913
6914
2/2
✓ Branch 0 taken 1974 times.
✓ Branch 1 taken 714 times.
2688 if(clk2>=48)
6915 {
6916 714 fr4=0;
6917 714 }
6918
6919
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 384 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1024 times.
2688 switch(dir)
6920 {
6921 case up:
6922 256 tile+=28+fr4;
6923 256 yofs+=8;
6924 256 dummy_int[1]=-20; //second tile change
6925 256 dummy_int[2]=0; //new xofs change
6926 256 dummy_int[3]=-16; //new xofs change
6927 256 break;
6928
6929 case down:
6930 384 tile+=12+fr4;
6931 384 yofs-=8;
6932 384 dummy_int[1]=20; //second tile change
6933 384 dummy_int[2]=0; //new xofs change
6934 384 dummy_int[3]=16; //new xofs change
6935 384 break;
6936
6937 case left:
6938 1024 tile+=49+(2*fr4);
6939 1024 xofs+=8;
6940 1024 dummy_int[1]=-1; //second tile change
6941 1024 dummy_int[2]=-16; //new xofs change
6942 1024 dummy_int[3]=0; //new xofs change
6943 1024 break;
6944
6945 case right:
6946 1024 tile+=69+(2*fr4);
6947 1024 xofs+=8;
6948 1024 dummy_int[1]=-1; //second tile change
6949 1024 dummy_int[2]=-16; //new xofs change
6950 1024 dummy_int[3]=0; //new xofs change
6951 1024 break;
6952 }
6953 2688 }
6954
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 34987 times.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 661 times.
36145 else if(!dying || clk2>19)
6955 {
6956 // normal
6957
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7136 times.
✓ Branch 2 taken 6672 times.
✓ Branch 3 taken 11075 times.
✓ Branch 4 taken 10601 times.
35484 switch(dir)
6958 {
6959 case up:
6960 7136 tile+=20+((clk&24)>>3);
6961 7136 yofs+=8;
6962 7136 dummy_int[1]=-20; //second tile change
6963 7136 dummy_int[2]=0; //new xofs change
6964 7136 dummy_int[3]=-16; //new xofs change
6965 7136 break;
6966
6967 case down:
6968 6672 tile+=4+((clk&24)>>3);
6969 6672 yofs-=8;
6970 6672 dummy_int[1]=20; //second tile change
6971 6672 dummy_int[2]=0; //new xofs change
6972 6672 dummy_int[3]=16; //new xofs change
6973 6672 break;
6974
6975 case left:
6976 11075 xofs=-8;
6977 11075 tile+=40+((clk&24)>>2);
6978 11075 dummy_int[1]=1; //second tile change
6979 11075 dummy_int[2]=16; //new xofs change
6980 11075 dummy_int[3]=0; //new xofs change
6981 11075 break;
6982
6983 case right:
6984 10601 tile+=60+((clk&24)>>2);
6985 10601 xofs=-8;
6986 10601 dummy_int[1]=1; //second tile change
6987 10601 dummy_int[2]=16; //new xofs change
6988 10601 dummy_int[3]=0; //new xofs change
6989 10601 break;
6990 }
6991 35484 }
6992 }
6993 38833 break;
6994
6995 case aWIZZ:
6996 {
6997 // if(d->misc1)
6998
2/2
✓ Branch 0 taken 182184 times.
✓ Branch 1 taken 273190 times.
455374 if(dmisc1)
6999 {
7000
2/2
✓ Branch 0 taken 91057 times.
✓ Branch 1 taken 91127 times.
182184 if(clk&8)
7001 {
7002 91127 ++tile;
7003 91127 }
7004 182184 }
7005 else
7006 {
7007
2/2
✓ Branch 0 taken 136701 times.
✓ Branch 1 taken 136489 times.
273190 if(frame&4)
7008 {
7009 136489 ++tile;
7010 136489 }
7011 }
7012
7013
4/4
✓ Branch 0 taken 76094 times.
✓ Branch 1 taken 157108 times.
✓ Branch 2 taken 145581 times.
✓ Branch 3 taken 76591 times.
455374 switch(dir)
7014 {
7015 case 9:
7016 case 15:
7017 case up:
7018 76094 tile+=2;
7019 76094 break;
7020
7021 case down:
7022 76591 break;
7023
7024 case 13:
7025 case left:
7026 157108 flip=1;
7027 157108 break;
7028
7029 default:
7030 145581 flip=0;
7031 145581 break;
7032 }
7033 }
7034 455374 break;
7035
7036 case aNEWWIZZ:
7037 {
7038 1519575 tiledir(dir,true);
7039
7040 // if(d->misc1) //walking wizzrobe
7041
2/2
✓ Branch 0 taken 742424 times.
✓ Branch 1 taken 777151 times.
1519575 if(dmisc1) //walking wizzrobe
7042 {
7043
2/2
✓ Branch 0 taken 373321 times.
✓ Branch 1 taken 369103 times.
742424 if(clk&8)
7044 {
7045 369103 tile+=2;
7046 369103 }
7047
7048
2/2
✓ Branch 0 taken 372085 times.
✓ Branch 1 taken 370339 times.
742424 if(clk&4)
7049 {
7050 370339 tile+=1;
7051 370339 }
7052
7053
2/4
✓ Branch 0 taken 742424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 742424 times.
742424 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7054 {
7055
2/2
✓ Branch 0 taken 663262 times.
✓ Branch 1 taken 79162 times.
742424 if(dummy_int[1]>0)
7056 {
7057 79162 tile+=40;
7058 79162 }
7059 742424 }
7060 742424 }
7061 else
7062 {
7063
4/4
✓ Branch 0 taken 710492 times.
✓ Branch 1 taken 66659 times.
✓ Branch 2 taken 167559 times.
✓ Branch 3 taken 542933 times.
777151 if(dummy_bool[1]||dummy_bool[2])
7064 {
7065 234218 tile+=20;
7066
7067
2/2
✓ Branch 0 taken 66650 times.
✓ Branch 1 taken 167568 times.
234218 if(dummy_bool[2])
7068 {
7069 167568 tile+=20;
7070 167568 }
7071 234218 }
7072
7073 777151 tile+=((frame>>1)&3);
7074 }
7075 }
7076 1519575 break;
7077
7078 case a3FRM:
7079 {
7080
2/2
✓ Branch 0 taken 46675 times.
✓ Branch 1 taken 150367 times.
197042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7081 }
7082 197042 break;
7083
7084 case a3FRM4DIR:
7085 {
7086 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7087 }
7088 break;
7089
7090 case aVIRE:
7091 {
7092
2/2
✓ Branch 0 taken 99588 times.
✓ Branch 1 taken 29292 times.
128880 if(dir==up)
7093 {
7094 29292 tile+=2;
7095 29292 }
7096
7097 128880 tile+=fx;
7098 }
7099 128880 break;
7100
7101 case aROPE:
7102 {
7103 220021 tile+=(1-fx);
7104 220021 flip = dir==left ? 1:0;
7105 }
7106 220021 break;
7107
7108 case aZORA:
7109 {
7110 int32_t dl;
7111
7112
2/2
✓ Branch 0 taken 46739 times.
✓ Branch 1 taken 174898 times.
221637 if(clk<36)
7113 {
7114 46739 dl=clk+5;
7115 46739 goto waves2;
7116 }
7117
7118
2/2
✓ Branch 0 taken 82440 times.
✓ Branch 1 taken 92458 times.
174898 if(clk<36+66)
7119
2/2
✓ Branch 0 taken 50715 times.
✓ Branch 1 taken 31725 times.
82440 tile=(dir==up)?o_tile+1:o_tile;
7120 else
7121 {
7122 92458 dl=clk-36-66;
7123 waves2:
7124 139197 tile=((dl/11)&1)+s_tile;
7125 139197 basetile = s_tile;
7126 }
7127 }
7128 221637 break;
7129
7130 case aNEWZORA:
7131 {
7132 686882 f4=(clk/16)%4;
7133
7134 686882 tiledir(dir,true);
7135 int32_t dl;
7136
7137
4/4
✓ Branch 0 taken 485838 times.
✓ Branch 1 taken 201044 times.
✓ Branch 2 taken 249250 times.
✓ Branch 3 taken 236588 times.
686882 if((clk>35)&&(clk<36+67)) //surfaced
7138 {
7139
4/4
✓ Branch 0 taken 202239 times.
✓ Branch 1 taken 34349 times.
✓ Branch 2 taken 29164 times.
✓ Branch 3 taken 173075 times.
236588 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7140 {
7141 173075 tile+=80;
7142 173075 } //mouth closed
7143 else
7144 {
7145 63513 tile+=40;
7146 }
7147
7148 236588 tile+=f4;
7149 236588 }
7150 else
7151 {
7152
2/2
✓ Branch 0 taken 201044 times.
✓ Branch 1 taken 249250 times.
450294 if(clk<36)
7153 {
7154 201044 dl=clk+5;
7155 201044 }
7156 else
7157 {
7158 249250 dl=clk-36-66;
7159 }
7160
7161 450294 tile+=((dl/5)&3);
7162 }
7163 }
7164 686882 break;
7165
7166 case a4FRM4EYE:
7167 case a2FRM4EYE:
7168 case a4FRM8EYE:
7169 case a4FRM8EYEB: //big version
7170 case a4FRM4EYEB:
7171 {
7172 836734 tilerows = 2;
7173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakex = x + 8*(zc_max(1,txsz)-1);
7174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakey = y + 8*(zc_max(1,tysz)-1);
7175 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7176 836734 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7177 836734 int32_t lookat=zc_oldrand()&15;
7178
7179
4/4
✓ Branch 0 taken 272091 times.
✓ Branch 1 taken 564643 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 210774 times.
836734 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7180 {
7181 210774 lookat=l_down;
7182 210774 }
7183
4/4
✓ Branch 0 taken 288167 times.
✓ Branch 1 taken 337793 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 226850 times.
625960 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7184 {
7185 226850 lookat=down;
7186 226850 }
7187
4/4
✓ Branch 0 taken 170154 times.
✓ Branch 1 taken 228956 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 108837 times.
399110 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7188 {
7189 108837 lookat=r_down;
7190 108837 }
7191
4/4
✓ Branch 0 taken 131712 times.
✓ Branch 1 taken 158561 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 70395 times.
290273 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7192 {
7193 70395 lookat=right;
7194 70395 }
7195
4/4
✓ Branch 0 taken 96384 times.
✓ Branch 1 taken 123494 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 35067 times.
219878 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7196 {
7197 35067 lookat=r_up;
7198 35067 }
7199
4/4
✓ Branch 0 taken 86753 times.
✓ Branch 1 taken 98058 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 25436 times.
184811 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7200 {
7201 25436 lookat=up;
7202 25436 }
7203
4/4
✓ Branch 0 taken 98120 times.
✓ Branch 1 taken 61255 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 36803 times.
159375 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7204 {
7205 36803 lookat=l_up;
7206 36803 }
7207 else
7208 {
7209 122572 lookat=left;
7210 }
7211
7212 836734 int32_t dir2 = dir;
7213 836734 dir = lookat;
7214
3/6
✓ Branch 0 taken 836734 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 836734 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 836734 times.
836734 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7215 else
7216 {
7217 tiledir_big(dir,(anim == a4FRM4EYEB));
7218 tile+=2*f4;
7219 ignore_extend = true;
7220 }
7221 836734 dir = dir2;
7222 }
7223 836734 break;
7224
7225 case aFLIP:
7226 {
7227 1690654 flip = f2&1;
7228 }
7229 1690654 break;
7230
7231 case a2FRM:
7232 {
7233 1133827 tile += (1-f2);
7234 }
7235 1133827 break;
7236
7237 case a2FRMB:
7238 {
7239 tile+= 2*(1-f2);
7240 ignore_extend = true;
7241 }
7242 break;
7243
7244 case a2FRM4DIR:
7245 {
7246 267131 basetile = n_frame_n_dir(2, 4, f2&1);
7247 }
7248 267131 break;
7249
7250 case a4FRM4DIRF:
7251 {
7252 4117708 basetile = n_frame_n_dir(4,4,f4);
7253
7254
2/2
✓ Branch 0 taken 2717716 times.
✓ Branch 1 taken 1399992 times.
4117708 if(clk2>0) //stopped to fire
7255 {
7256 1399992 tile+=20;
7257
7258
2/2
✓ Branch 0 taken 697526 times.
✓ Branch 1 taken 702466 times.
1399992 if(clk2<17) //firing
7259 {
7260 702466 tile+=20;
7261 702466 }
7262 1399992 }
7263 }
7264 4117708 break;
7265
7266 case a4FRM4DIR:
7267 {
7268 7475916 basetile = n_frame_n_dir(4,4,f4);
7269 }
7270 7475916 break;
7271
7272 case a4FRM8DIRF:
7273 {
7274 tilerows = 2;
7275 basetile = n_frame_n_dir(4,8,f4);
7276
7277 if(clk2>0) //stopped to fire
7278 {
7279 tile+=40;
7280
7281 if(clk2<17) //firing
7282 {
7283 tile+=40;
7284 }
7285 }
7286 }
7287 break;
7288
7289 case a4FRM8DIRB:
7290 case a4FRM8DIRFB:
7291 {
7292 3868 tilerows = 2;
7293 3868 tiledir_big(dir,false);
7294 3868 tile+=2*f4;
7295
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7296 {
7297 tile+=80;
7298
7299 if(clk2<17) //firing
7300 {
7301 tile+=80;
7302 }
7303 }
7304 3868 ignore_extend = true;
7305 }
7306 3868 break;
7307
7308 case a4FRM4DIRB:
7309 case a4FRM4DIRFB:
7310 {
7311 tilerows = 2;
7312 tiledir_big(dir,true);
7313 tile+=2*f4;
7314 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7315 {
7316 tile+=40;
7317
7318 if(clk2<17) //firing
7319 {
7320 tile+=40;
7321 }
7322 }
7323 ignore_extend = true;
7324 }
7325 break;
7326
7327 case aOCTO:
7328 {
7329
5/5
✓ Branch 0 taken 4152 times.
✓ Branch 1 taken 122459 times.
✓ Branch 2 taken 133448 times.
✓ Branch 3 taken 165605 times.
✓ Branch 4 taken 157127 times.
582791 switch(dir)
7330 {
7331 case up:
7332 122459 flip = 2;
7333 122459 break;
7334
7335 case down:
7336 133448 flip = 0;
7337 133448 break;
7338
7339 case left:
7340 165605 flip = 0;
7341 165605 tile += 2;
7342 165605 break;
7343
7344 case right:
7345 157127 flip = 1;
7346 157127 tile += 2;
7347 157127 break;
7348 }
7349
7350 582791 tile+=f2;
7351 }
7352 582791 break;
7353
7354 case aWALK:
7355 {
7356
5/5
✓ Branch 0 taken 5614 times.
✓ Branch 1 taken 248704 times.
✓ Branch 2 taken 267165 times.
✓ Branch 3 taken 331694 times.
✓ Branch 4 taken 325802 times.
1178979 switch(dir)
7357 {
7358 case up:
7359 248704 tile+=3;
7360 248704 flip = f2;
7361 248704 break;
7362
7363 case down:
7364 267165 tile+=2;
7365 267165 flip = f2;
7366 267165 break;
7367
7368 case left:
7369 331694 flip=1;
7370 331694 tile += f2;
7371 331694 break;
7372
7373 case right:
7374 325802 flip=0;
7375 325802 tile += f2;
7376 325802 break;
7377 }
7378 }
7379 1178979 break;
7380
7381 case aDWALK:
7382 {
7383
3/4
✓ Branch 0 taken 92330 times.
✓ Branch 1 taken 787846 times.
✓ Branch 2 taken 92330 times.
✗ Branch 3 not taken.
880176 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7384 {
7385 tile=s_tile;
7386 basetile = s_tile;
7387 }
7388
7389
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 177728 times.
✓ Branch 2 taken 185581 times.
✓ Branch 3 taken 260885 times.
✓ Branch 4 taken 255982 times.
880176 switch(dir)
7390 {
7391 case up:
7392 177728 tile+=2;
7393 177728 flip=f2;
7394 177728 break;
7395
7396 case down:
7397 185581 flip=0;
7398 185581 tile+=(1-f2);
7399 185581 break;
7400
7401 case left:
7402 260885 flip=1;
7403 260885 tile+=(3+f2);
7404 260885 break;
7405
7406 case right:
7407 255982 flip=0;
7408 255982 tile+=(3+f2);
7409 255982 break;
7410 }
7411 }
7412 880176 break;
7413
7414 case aTEK:
7415 {
7416
2/2
✓ Branch 0 taken 139654 times.
✓ Branch 1 taken 79014 times.
218668 if(misc==0)
7417 {
7418 79014 tile += f2;
7419 79014 }
7420
2/2
✓ Branch 0 taken 72936 times.
✓ Branch 1 taken 66718 times.
139654 else if(misc!=1)
7421 {
7422 66718 ++tile;
7423 66718 }
7424 }
7425 218668 break;
7426
7427 case aNEWTEK:
7428 {
7429
2/2
✓ Branch 0 taken 474700 times.
✓ Branch 1 taken 1337360 times.
1812060 if(step<0) //up
7430 {
7431
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 235321 times.
✓ Branch 2 taken 239379 times.
474700 switch(clk3)
7432 {
7433 case left:
7434 235321 flip=0;
7435 235321 tile+=20;
7436 235321 break;
7437
7438 case right:
7439 239379 flip=0;
7440 239379 tile+=24;
7441 239379 break;
7442 }
7443 474700 }
7444
2/2
✓ Branch 0 taken 54741 times.
✓ Branch 1 taken 1282619 times.
1337360 else if(step==0)
7445 {
7446
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 40562 times.
✓ Branch 2 taken 14179 times.
54741 switch(clk3)
7447 {
7448 case left:
7449 40562 flip=0;
7450 40562 tile+=8;
7451 40562 break;
7452
7453 case right:
7454 14179 flip=0;
7455 14179 tile+=12;
7456 14179 break;
7457 }
7458 54741 } //down
7459 else
7460 {
7461
3/3
✓ Branch 0 taken 104875 times.
✓ Branch 1 taken 592792 times.
✓ Branch 2 taken 584952 times.
1282619 switch(clk3)
7462 {
7463 case left:
7464 592792 flip=0;
7465 592792 tile+=28;
7466 592792 break;
7467
7468 case right:
7469 584952 flip=0;
7470 584952 tile+=32;
7471 584952 break;
7472 }
7473 }
7474
7475
2/2
✓ Branch 0 taken 1232959 times.
✓ Branch 1 taken 579101 times.
1812060 if(misc==0)
7476 {
7477 579101 tile+=f4;
7478 579101 }
7479
2/2
✓ Branch 0 taken 577625 times.
✓ Branch 1 taken 655334 times.
1232959 else if(misc!=1)
7480 {
7481 655334 tile+=2;
7482 655334 }
7483 }
7484 1812060 break;
7485
7486 case aARMOS:
7487 {
7488
2/2
✓ Branch 0 taken 3227 times.
✓ Branch 1 taken 5401 times.
8628 if(!fading)
7489 {
7490 5401 tile += fx;
7491
7492
2/2
✓ Branch 0 taken 4204 times.
✓ Branch 1 taken 1197 times.
5401 if(dir==up)
7493 1197 tile += 2;
7494 5401 }
7495 }
7496 8628 break;
7497
7498 case aARMOS4:
7499 {
7500
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 28561 times.
✓ Branch 2 taken 85620 times.
✓ Branch 3 taken 42992 times.
✓ Branch 4 taken 42164 times.
199337 switch(dir)
7501 {
7502 case up:
7503 28561 flip=0;
7504 28561 break;
7505
7506 case down:
7507 85620 flip=0;
7508 85620 tile+=4;
7509 85620 break;
7510
7511 case left:
7512 42992 flip=0;
7513 42992 tile+=8;
7514 42992 break;
7515
7516 case right:
7517 42164 flip=0;
7518 42164 tile+=12;
7519 42164 break;
7520 }
7521
7522
2/2
✓ Branch 0 taken 59607 times.
✓ Branch 1 taken 139730 times.
199337 if(!fading)
7523 {
7524 139730 tile+=f4;
7525 139730 }
7526 }
7527 199337 break;
7528
7529 case aGHINI:
7530 {
7531
4/4
✓ Branch 0 taken 28037 times.
✓ Branch 1 taken 32092 times.
✓ Branch 2 taken 72763 times.
✓ Branch 3 taken 452 times.
133344 switch(dir)
7532 {
7533 case 8:
7534 case 9:
7535 case up:
7536 28037 ++tile;
7537 28037 flip=0;
7538 28037 break;
7539
7540 case 15:
7541 452 ++tile;
7542 452 flip=1;
7543 452 break;
7544
7545 case 10:
7546 case 11:
7547 case right:
7548 32092 flip=1;
7549 32092 break;
7550
7551 default:
7552 72763 flip=0;
7553 72763 break;
7554 }
7555 }
7556 133344 break;
7557
7558 case a2FRMPOS:
7559 {
7560 1755010 tile+=posframe;
7561 }
7562 1755010 break;
7563
7564 case a4FRMPOS4DIR:
7565 {
7566 363745 basetile = n_frame_n_dir(4,4,0);
7567 // tile+=f2;
7568 363745 tile+=posframe;
7569 }
7570 363745 break;
7571
7572 case a4FRMPOS4DIRF:
7573 {
7574 1433 basetile = n_frame_n_dir(4,4,0);
7575
7576
2/2
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 197 times.
1433 if(clk2>0) //stopped to fire
7577 {
7578 197 tile+=20;
7579
7580
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 64 times.
197 if(clk2<17) //firing
7581 {
7582 64 tile+=20;
7583 64 }
7584 197 }
7585
7586 // tile+=f2;
7587 1433 tile+=posframe;
7588 }
7589 1433 break;
7590
7591 case a4FRMPOS8DIR:
7592 {
7593 6953976 tilerows = 2;
7594 6953976 int32_t n = tile;
7595 6953976 basetile = n_frame_n_dir(4,8,0);
7596 // tile+=f2;
7597 6953976 tile+=posframe;
7598 }
7599 6953976 break;
7600
7601 case a4FRMPOS8DIRF:
7602 {
7603 tilerows = 2;
7604 basetile = n_frame_n_dir(4,8,0);
7605
7606 if(clk2>0) //stopped to fire
7607 {
7608 tile+=40;
7609
7610 if(clk2<17) //firing
7611 {
7612 tile+=40;
7613 }
7614 }
7615
7616 tile+=posframe;
7617 }
7618 break;
7619
7620 case aNEWLEV:
7621 {
7622 747030 tiledir(dir,true);
7623
7624
4/5
✓ Branch 0 taken 258994 times.
✓ Branch 1 taken 115368 times.
✓ Branch 2 taken 48980 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 323688 times.
747030 switch(misc)
7625 {
7626 case -1:
7627 case 0:
7628 258994 return;
7629
7630 case 1:
7631
7632 // case 5: cs = d->misc2; break;
7633 case 5:
7634 115368 cs = dmisc2;
7635 115368 break;
7636
7637 case 2:
7638 case 4:
7639 48980 tile += 20;
7640 48980 break;
7641
7642 case 3:
7643 323688 tile += 40;
7644 323688 break;
7645 }
7646
7647 488036 tile+=f4;
7648 }
7649 488036 break;
7650
7651 case aLEV:
7652 {
7653 276997 f4 = ((clk/5)&1);
7654
7655
4/5
✓ Branch 0 taken 127945 times.
✓ Branch 1 taken 33336 times.
✓ Branch 2 taken 14658 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101058 times.
276997 switch(misc)
7656 {
7657 case -1:
7658 case 0:
7659 127945 return;
7660
7661 case 1:
7662
7663 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7664 case 5:
7665 33336 tile += (f2) ? 1 : 0;
7666 33336 cs = dmisc2;
7667 33336 break;
7668
7669 case 2:
7670 case 4:
7671 14658 tile += 2;
7672 14658 break;
7673
7674 case 3:
7675 101058 tile += (f4) ? 4 : 3;
7676 101058 break;
7677 }
7678 }
7679 149052 break;
7680
7681 case aWALLM:
7682 {
7683
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 139764 times.
140514 if(!dummy_bool[1])
7684 {
7685 139764 tile += f2;
7686 139764 }
7687 }
7688 140514 break;
7689
7690 case aNEWWALLM:
7691 {
7692 366633 int32_t tempdir=0;
7693
7694
4/4
✓ Branch 0 taken 38855 times.
✓ Branch 1 taken 43340 times.
✓ Branch 2 taken 8438 times.
✓ Branch 3 taken 276000 times.
366633 switch(misc)
7695 {
7696 case 1:
7697 case 2:
7698 43340 tempdir=clk3;
7699 43340 break;
7700
7701 case 3:
7702 case 4:
7703 case 5:
7704 38855 tempdir=dir;
7705 38855 break;
7706
7707 case 6:
7708 case 7:
7709 8438 tempdir=clk3^1;
7710 8438 break;
7711 }
7712
7713 366633 tiledir(tempdir,true);
7714
7715
2/2
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 364725 times.
366633 if(!dummy_bool[1])
7716 {
7717 364725 tile+=f4;
7718 364725 }
7719 }
7720 366633 break;
7721
7722 case a4FRMNODIR:
7723 {
7724 171508 tile+=f4;
7725 }
7726 171508 break;
7727
7728 } // switch(d->anim)
7729
7730 // flashing
7731 // if(d->flags & guy_flashing)
7732
2/2
✓ Branch 0 taken 38758945 times.
✓ Branch 1 taken 743628 times.
39502573 if(flags & guy_flashing)
7733 {
7734 743628 cs = (frame&3) + 6;
7735 743628 }
7736
7737
2/2
✓ Branch 0 taken 39091625 times.
✓ Branch 1 taken 410948 times.
39502573 if(flags&guy_transparent)
7738 {
7739 410948 drawstyle=1;
7740 410948 }
7741
7742 39502573 int32_t change = tile-basetile;
7743
7744
3/6
✓ Branch 0 taken 1942794 times.
✓ Branch 1 taken 37559779 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1942794 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
39502573 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7745 {
7746
2/2
✓ Branch 0 taken 1681192 times.
✓ Branch 1 taken 261602 times.
1942794 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7747 {
7748 1681192 tile=basetile+txsz*change;
7749 1681192 }
7750 else
7751 {
7752 261602 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7753 }
7754 1942794 }
7755 else
7756 {
7757 37559779 tile=basetile+change;
7758 }
7759 39891825 }
7760
7761 81078 int32_t enemy::wpnsfx(int32_t wpn)
7762 {
7763
3/3
✓ Branch 0 taken 22419 times.
✓ Branch 1 taken 40952 times.
✓ Branch 2 taken 17707 times.
81078 switch (wpn)
7764 {
7765 case wScript1:
7766 case wScript2:
7767 case wScript3:
7768 case wScript4:
7769 case wScript5:
7770 case wScript6:
7771 case wScript7:
7772 case wScript8:
7773 case wScript9:
7774 case wScript10: //sure why not
7775 case ewFireTrail:
7776 case ewFlame:
7777 case ewFlame2Trail:
7778 case ewFlame2:
7779 case ewWind:
7780 case ewMagic:
7781 case ewIce:
7782 22419 return firesfx;
7783
7784 case ewRock:
7785 case ewFireball2:
7786 case ewFireball:
7787
2/2
✓ Branch 0 taken 5494 times.
✓ Branch 1 taken 35458 times.
40952 if (get_qr(qr_MORESOUNDS)) return firesfx;
7788 35458 break;
7789 }
7790
7791 53165 return 0;
7792 81078 }
7793
7794 76625588 int32_t enemy::run_script(int32_t mode)
7795 {
7796
3/4
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 76625332 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
76625588 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7797
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76625332 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
76625332 if (script <= 0 || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7798 76625332 return RUNSCRIPT_OK;
7799 auto scrty = *get_scrtype();
7800 auto uid = getUID();
7801 if(!FFCore.doscript(scrty,uid))
7802 return RUNSCRIPT_OK;
7803 int32_t ret = RUNSCRIPT_OK;
7804 bool& waitdraw = FFCore.waitdraw(scrty, uid);
7805 switch(mode)
7806 {
7807 case MODE_NORMAL:
7808 return ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7809 case MODE_WAITDRAW:
7810 if(waitdraw)
7811 {
7812 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7813 waitdraw = false;
7814 }
7815 break;
7816 }
7817 return ret;
7818 76625588 }
7819 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7820 {
7821 return al_map_rgba(255,0,0,opacity);
7822 }
7823
7824 // good guys, fires, fairy, and other non-enemies
7825 // based on enemy class b/c guys in dungeons act sort of like enemies
7826 // also easier to manage all the guys this way
7827 2178 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7828 2178 {
7829 2178 mainguy=mg;
7830 2178 canfreeze=false;
7831 2178 dir=down;
7832
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2178 times.
✓ Branch 2 taken 2178 times.
✗ Branch 3 not taken.
2178 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7833 2178 hxofs=2;
7834 2178 hzsz=8;
7835 2178 hit_width=12;
7836 2178 hit_height=17;
7837
7838
10/12
✓ Branch 0 taken 2178 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2178 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 765 times.
✓ Branch 5 taken 1413 times.
✓ Branch 6 taken 743 times.
✓ Branch 7 taken 22 times.
✓ Branch 8 taken 276 times.
✓ Branch 9 taken 467 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 260 times.
2178 if(!superman && (!isdungeon() || id==gFAIRY || id==gFIRE || id==gZELDA))
7839 {
7840 1918 superman = 1;
7841 1918 hxofs=1000;
7842 1918 }
7843 2178 }
7844
7845 938182 bool guy::animate(int32_t index)
7846 {
7847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 938182 times.
938182 if(switch_hooked) return enemy::animate(index);
7848
6/6
✓ Branch 0 taken 539004 times.
✓ Branch 1 taken 399178 times.
✓ Branch 2 taken 8214 times.
✓ Branch 3 taken 530790 times.
✓ Branch 4 taken 7017 times.
✓ Branch 5 taken 1197 times.
938182 if(mainguy && clk==0 && misc==0)
7849 {
7850 1197 setupscreen();
7851 1197 misc = 1;
7852 1197 }
7853
7854
4/4
✓ Branch 0 taken 539004 times.
✓ Branch 1 taken 399178 times.
✓ Branch 2 taken 538676 times.
✓ Branch 3 taken 328 times.
938182 if(mainguy && fadeclk==0)
7855 328 return true;
7856
7857 937854 hp=256; // good guys never die...
7858
7859
4/4
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 936932 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 16 times.
937854 if(hclk && !clk2)
7860 {
7861 // but if they get hit...
7862 16 ++clk2; // only do this once
7863
7864
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7 times.
16 if(!get_qr(qr_NOGUYFIRES))
7865 {
7866 7 addenemy(BSZ?64:72,68,eSHOOTFBALL,0);
7867 7 addenemy(BSZ?176:168,68,eSHOOTFBALL,0);
7868 7 }
7869 16 }
7870
7871 937854 return enemy::animate(index);
7872 938182 }
7873
7874 941952 void guy::draw(BITMAP *dest)
7875 {
7876 941952 update_enemy_frame();
7877
7878
6/6
✓ Branch 0 taken 542567 times.
✓ Branch 1 taken 399385 times.
✓ Branch 2 taken 22779 times.
✓ Branch 3 taken 519788 times.
✓ Branch 4 taken 10998 times.
✓ Branch 5 taken 11781 times.
941952 if(!mainguy || fadeclk<0 || fadeclk&1)
7879 930171 enemy::draw(dest);
7880 941952 }
7881
7882 759 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7883 759 {
7884 759 clk4=0;
7885
4/8
✓ Branch 0 taken 759 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 759 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 759 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 759 times.
✗ Branch 7 not taken.
759 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7886 // Spawn type
7887
2/4
✓ Branch 0 taken 759 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 759 times.
759 if(flags & guy_fade_flicker)
7888 {
7889 clk=0;
7890 superman = 1;
7891 fading=fade_flicker;
7892 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7893 dir=down;
7894
7895 if(!canmove(down,(zfix)8,spw_none,false))
7896 clk3=int32_t(13.0/step);
7897 }
7898
3/4
✓ Branch 0 taken 759 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 676 times.
✓ Branch 3 taken 83 times.
759 else if(flags & guy_fade_instant)
7899 {
7900 83 clk=0;
7901 83 }
7902
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 759 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
759 if (SIZEflags != 0) init_size_flags();;
7903 759 }
7904
7905 167471 bool eFire::animate(int32_t index)
7906 {
7907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167471 times.
167471 if(switch_hooked) return enemy::animate(index);
7908
2/4
✓ Branch 0 taken 167471 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167471 times.
167471 if(fallclk||drownclk) return enemy::animate(index);
7909
2/2
✓ Branch 0 taken 165755 times.
✓ Branch 1 taken 1716 times.
167471 if(fading)
7910 {
7911
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1715 times.
1716 if(++clk4 > 60)
7912 {
7913 1 clk4=0;
7914 1 superman=0;
7915 1 fading=0;
7916
7917
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags&guy_armos && z==0 && fakez==0)
7918 removearmos(x,y,ffcactivated);
7919
7920 1 clk2=0;
7921
7922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!canmove(down,(zfix)8,spw_none,false))
7923 {
7924 1 dir=0;
7925 1 y = y.getInt() & 0xF0;
7926 1 }
7927
7928 1 return Dead(index);
7929 }
7930
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1715 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1715 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
7931 removearmos(x,y,ffcactivated);
7932 1715 }
7933
7934 167470 return enemy::animate(index);
7935 167471 }
7936
7937 351657 void eFire::draw(BITMAP *dest)
7938 {
7939 351657 update_enemy_frame();
7940 351657 enemy::draw(dest);
7941 351657 }
7942
7943 415 int32_t eFire::takehit(weapon *w, weapon* realweap)
7944 {
7945 415 int32_t wpnId = w->id;
7946 415 int32_t wpnDir = w->dir;
7947
7948
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
415 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7949 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
7950 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
7951 {
7952 shield = false;
7953 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
7954
7955 if(get_qr(qr_BRKNSHLDTILES))
7956 o_tile=s_tile;
7957 }
7958
7959 415 int32_t ret = enemy::takehit(w,realweap);
7960 415 return ret;
7961 }
7962
7963 void eFire::break_shield()
7964 {
7965 if(!shield)
7966 return;
7967
7968 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
7969 shield=false;
7970
7971 if(get_qr(qr_BRKNSHLDTILES))
7972 o_tile=s_tile;
7973 }
7974
7975 7314 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7976 7314 {
7977 7314 clk4=0;
7978
4/8
✓ Branch 0 taken 7314 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7314 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7314 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7314 times.
✗ Branch 7 not taken.
7314 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7979
7980 // Spawn type
7981
2/4
✓ Branch 0 taken 7314 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7314 times.
7314 if(flags & guy_fade_flicker)
7982 {
7983 clk=0;
7984 superman = 1;
7985 fading=fade_flicker;
7986 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7987 dir=down;
7988
7989 if(!canmove(down,(zfix)8,spw_none,false))
7990 clk3=int32_t(13.0/step);
7991 }
7992
3/4
✓ Branch 0 taken 7314 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6133 times.
✓ Branch 3 taken 1181 times.
7314 else if(flags & guy_fade_instant)
7993 {
7994 1181 clk=0;
7995 1181 }
7996
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7307 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7314 if (SIZEflags != 0) init_size_flags();;
7997 7314 }
7998
7999 1872314 bool eOther::animate(int32_t index)
8000 {
8001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1872314 times.
1872314 if(switch_hooked) return enemy::animate(index);
8002
3/4
✓ Branch 0 taken 1870797 times.
✓ Branch 1 taken 1517 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1870797 times.
1872314 if(fallclk||drownclk) return enemy::animate(index);
8003
2/2
✓ Branch 0 taken 1862383 times.
✓ Branch 1 taken 8414 times.
1870797 if(fading)
8004 {
8005
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 8387 times.
8414 if(++clk4 > 60)
8006 {
8007 27 clk4=0;
8008 27 superman=0;
8009 27 fading=0;
8010
8011
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27 if(flags&guy_armos && z==0 && fakez==0)
8012 removearmos(x,y,ffcactivated);
8013
8014 27 clk2=0;
8015
8016
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 2 times.
27 if(!canmove(down,(zfix)8,spw_none,false))
8017 {
8018 2 dir=0;
8019 2 y = y.getInt() & 0xF0;
8020 2 }
8021
8022 27 return Dead(index);
8023 }
8024
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8387 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8025 removearmos(x,y,ffcactivated);
8026 8387 }
8027
8028 1870770 return enemy::animate(index);
8029 1872314 }
8030
8031 1975750 void eOther::draw(BITMAP *dest)
8032 {
8033 1975750 update_enemy_frame();
8034 1975750 enemy::draw(dest);
8035 1975750 }
8036
8037 14188 int32_t eOther::takehit(weapon *w, weapon* realweap)
8038 {
8039 14188 int32_t wpnId = w->id;
8040 14188 int32_t wpnDir = w->dir;
8041
8042
3/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 14163 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
14188 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8043 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8044 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8045 {
8046 shield = false;
8047 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8048
8049 if(get_qr(qr_BRKNSHLDTILES))
8050 o_tile=s_tile;
8051 }
8052
8053 14188 int32_t ret = enemy::takehit(w,realweap);
8054 14188 return ret;
8055 }
8056
8057 void eOther::break_shield()
8058 {
8059 if(!shield)
8060 return;
8061
8062 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8063 shield=false;
8064
8065 if(get_qr(qr_BRKNSHLDTILES))
8066 o_tile=s_tile;
8067 }
8068
8069
8070 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8071 {
8072 clk4=0;
8073 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8074
8075 // Spawn type
8076 if(flags & guy_fade_flicker)
8077 {
8078 clk=0;
8079 superman = 1;
8080 fading=fade_flicker;
8081 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8082 dir=down;
8083
8084 if(!canmove(down,(zfix)8,spw_none,false))
8085 clk3=int32_t(13.0/step);
8086 }
8087 else if(flags & guy_fade_instant)
8088 {
8089 clk=0;
8090 }
8091 if (SIZEflags != 0) init_size_flags();;
8092 }
8093
8094 bool eScript::animate(int32_t index)
8095 {
8096 if(switch_hooked) return enemy::animate(index);
8097 if(fallclk||drownclk) return enemy::animate(index);
8098 if(fading)
8099 {
8100 if(++clk4 > 60)
8101 {
8102 clk4=0;
8103 superman=0;
8104 fading=0;
8105
8106 if(flags&guy_armos && z==0 && fakez==0)
8107 removearmos(x,y,ffcactivated);
8108
8109 clk2=0;
8110
8111 if(!canmove(down,(zfix)8,spw_none,false))
8112 {
8113 dir=0;
8114 y = y.getInt() & 0xF0;
8115 }
8116
8117 return Dead(index);
8118 }
8119 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8120 removearmos(x,y,ffcactivated);
8121 }
8122
8123 return enemy::animate(index);
8124 }
8125
8126 void eScript::draw(BITMAP *dest)
8127 {
8128 update_enemy_frame();
8129 enemy::draw(dest);
8130 }
8131
8132 int32_t eScript::takehit(weapon *w, weapon* realweap)
8133 {
8134 int32_t wpnId = w->id;
8135 int32_t wpnDir = w->dir;
8136
8137 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8138 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8139 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8140 {
8141 shield = false;
8142 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8143
8144 if(get_qr(qr_BRKNSHLDTILES))
8145 o_tile=s_tile;
8146 }
8147
8148 int32_t ret = enemy::takehit(w,realweap);
8149 return ret;
8150 }
8151
8152 void eScript::break_shield()
8153 {
8154 if(!shield)
8155 return;
8156
8157 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8158 shield=false;
8159
8160 if(get_qr(qr_BRKNSHLDTILES))
8161 o_tile=s_tile;
8162 }
8163
8164
8165 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8166 {
8167 clk4=0;
8168 hyofs = -32768; //No hitbox initially.
8169 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8170
8171 // Spawn type
8172 if(flags & guy_fade_flicker)
8173 {
8174 clk=0;
8175 superman = 1;
8176 fading=fade_flicker;
8177 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8178 dir=down;
8179
8180 if(!canmove(down,(zfix)8,spw_none,false))
8181 clk3=int32_t(13.0/step);
8182 }
8183 else if(flags & guy_fade_instant)
8184 {
8185 clk=0;
8186 }
8187 if (SIZEflags != 0) init_size_flags();;
8188 }
8189
8190 bool eFriendly::animate(int32_t index)
8191 {
8192 if(switch_hooked) return enemy::animate(index);
8193 if(fallclk||drownclk) return enemy::animate(index);
8194 if(fading)
8195 {
8196 if(++clk4 > 60)
8197 {
8198 clk4=0;
8199 superman=0;
8200 fading=0;
8201
8202 if(flags&guy_armos && z==0 && fakez==0)
8203 removearmos(x,y,ffcactivated);
8204
8205 clk2=0;
8206
8207 if(!canmove(down,(zfix)8,spw_none,false))
8208 {
8209 dir=0;
8210 y = y.getInt() & 0xF0;
8211 }
8212
8213 return Dead(index);
8214 }
8215 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8216 removearmos(x,y,ffcactivated);
8217 }
8218
8219 return enemy::animate(index);
8220 }
8221
8222 void eFriendly::draw(BITMAP *dest)
8223 {
8224 update_enemy_frame();
8225 enemy::draw(dest);
8226 }
8227
8228 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8229 {
8230 int32_t wpnId = w->id;
8231 int32_t wpnDir = w->dir;
8232
8233 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8234 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8235 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8236 {
8237 shield = false;
8238 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8239
8240 if(get_qr(qr_BRKNSHLDTILES))
8241 o_tile=s_tile;
8242 }
8243
8244 int32_t ret = enemy::takehit(w,realweap);
8245 return ret;
8246 }
8247
8248 void eFriendly::break_shield()
8249 {
8250 if(!shield)
8251 return;
8252
8253 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8254 shield=false;
8255
8256 if(get_qr(qr_BRKNSHLDTILES))
8257 o_tile=s_tile;
8258 }
8259
8260
8261 779014 void enemy::removearmos(int32_t ax,int32_t ay, word ffcactive)
8262 {
8263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 779014 times.
779014 if (ffcactive)
8264 {
8265 removearmosffc(ffcactive-1);
8266 return;
8267 }
8268
2/2
✓ Branch 0 taken 778034 times.
✓ Branch 1 taken 980 times.
779014 if(did_armos)
8269 {
8270 778034 return;
8271 }
8272
8273 980 did_armos=true;
8274 980 ax&=0xF0;
8275 980 ay&=0xF0;
8276 980 int32_t cd = (ax>>4)+ay;
8277 980 int32_t f = MAPFLAG(ax,ay);
8278 980 int32_t f2 = MAPCOMBOFLAG(ax,ay);
8279
8280
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 140 times.
980 if(combobuf[tmpscr->data[cd]].type!=cARMOS)
8281 {
8282 840 return;
8283 }
8284
8285 140 tmpscr->data[cd] = tmpscr->undercombo;
8286 140 tmpscr->cset[cd] = tmpscr->undercset;
8287 140 tmpscr->sflag[cd] = 0;
8288
8289
3/4
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 118 times.
140 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8290 {
8291 22 tmpscr->data[cd] = tmpscr->secretcombo[sSTAIRS];
8292 22 tmpscr->cset[cd] = tmpscr->secretcset[sSTAIRS];
8293 22 tmpscr->sflag[cd]=tmpscr->secretflag[sSTAIRS];
8294 22 sfx(tmpscr->secretsfx);
8295 22 }
8296
8297
3/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 137 times.
140 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8298 {
8299
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8300 {
8301 3 additem(ax,ay,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8302 3 sfx(tmpscr->secretsfx);
8303 3 }
8304 3 }
8305
8306 140 putcombo(scrollbuf,ax,ay,tmpscr->data[cd],tmpscr->cset[cd]);
8307 779014 }
8308
8309 void enemy::removearmosffc(int32_t pos)
8310 {
8311 if(did_armos)
8312 {
8313 return;
8314 }
8315
8316 did_armos=true;
8317 ffcdata& ffc = tmpscr->getFFC(pos);
8318 newcombo const& cmb = combobuf[ffc.data];
8319 int32_t f2 = cmb.flag;
8320
8321 if(cmb.type!=cARMOS)
8322 {
8323 return;
8324 }
8325
8326 zc_ffc_set(ffc, tmpscr->undercombo);
8327 ffc.cset = tmpscr->undercset;
8328
8329 if(f2 == mfARMOS_SECRET)
8330 {
8331 zc_ffc_set(ffc, tmpscr->secretcombo[sSTAIRS]);
8332 ffc.cset = tmpscr->secretcset[sSTAIRS];
8333 sfx(tmpscr->secretsfx);
8334 }
8335
8336 if(f2 == mfARMOS_ITEM)
8337 {
8338 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8339 {
8340 additem(ffc.x,ffc.y,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8341 sfx(tmpscr->secretsfx);
8342 }
8343 }
8344
8345 putcombo(scrollbuf,ffc.x,ffc.y,ffc.data,ffc.cset);
8346 }
8347
8348
8349 461 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8350 461 {
8351 461 fading=fade_flicker;
8352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8353 461 dir=12;
8354 461 movestatus=1;
8355
1/2
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
461 step=0;
8356 461 clk=0;
8357 461 clk4=0;
8358
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if (SIZEflags != 0) init_size_flags();;
8359 461 }
8360
8361 117025 bool eGhini::animate(int32_t index)
8362 {
8363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117025 times.
117025 if(switch_hooked) return enemy::animate(index);
8364
2/4
✓ Branch 0 taken 117025 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 117025 times.
117025 if(fallclk||drownclk) return enemy::animate(index);
8365
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 116975 times.
117025 if(dying)
8366 50 return Dead(index);
8367
8368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116975 times.
116975 if(dmisc1)
8369 {
8370
2/2
✓ Branch 0 taken 89752 times.
✓ Branch 1 taken 27223 times.
116975 if(misc)
8371 {
8372
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 if(clk4>160)
8373 54853 misc=2;
8374
8375
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8376 89752 removearmos(x,y,ffcactivated);
8377 89752 }
8378
2/2
✓ Branch 0 taken 26798 times.
✓ Branch 1 taken 425 times.
27223 else if(clk4>=60)
8379 {
8380 425 misc=1;
8381 425 clk3=32;
8382 425 fading=0;
8383
1/2
✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
425 if (ffcactivated > 0)
8384 {
8385 guygridffc[ffcactivated-1] = 0;
8386 removearmosffc(ffcactivated-1);
8387 }
8388 else
8389 {
8390 425 guygrid[(int32_t(y)&0xF0)+(int32_t(x)>>4)]=0;
8391 425 removearmos(x,y);
8392 }
8393 425 }
8394 116975 }
8395
8396 116975 clk4++;
8397
8398 116975 return enemy::animate(index);
8399 117025 }
8400
8401 238808 void eGhini::draw(BITMAP *dest)
8402 {
8403 238808 update_enemy_frame();
8404 238808 enemy::draw(dest);
8405 238808 }
8406
8407 2 void eGhini::kickbucket()
8408 {
8409 2 hp=-1000; // don't call death_sfx()
8410 2 }
8411
8412
2/4
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5196 times.
✗ Branch 3 not taken.
10392 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8413 5196 {
8414
1/2
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
5196 old_y=y;
8415 5196 dir=down;
8416 5196 misc=1;
8417 5196 clk=-15;
8418
8419
2/2
✓ Branch 0 taken 2645 times.
✓ Branch 1 taken 2551 times.
5196 if(!BSZ)
8420
1/2
✓ Branch 0 taken 2645 times.
✗ Branch 1 not taken.
2645 clk*=zc_oldrand()%3+1;
8421
8422 // avoid divide by 0 errors
8423
1/2
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
5196 if(dmisc1 == 0)
8424 dmisc1 = 24;
8425
8426
1/2
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
5196 if(dmisc2 == 0)
8427 dmisc2 = 3;
8428
8429 //nets+760;
8430
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5196 if (SIZEflags != 0) init_size_flags();;
8431 5196 }
8432
8433 1435278 bool eTektite::animate(int32_t index)
8434 {
8435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1435278 times.
1435278 if(switch_hooked) return enemy::animate(index);
8436
4/4
✓ Branch 0 taken 1426328 times.
✓ Branch 1 taken 8950 times.
✓ Branch 2 taken 8950 times.
✓ Branch 3 taken 1423838 times.
1435278 if(fallclk||drownclk) return enemy::animate(index);
8437
2/2
✓ Branch 0 taken 26667 times.
✓ Branch 1 taken 1397171 times.
1423838 if(dying)
8438 26667 return Dead(index);
8439
8440
2/2
✓ Branch 0 taken 1360103 times.
✓ Branch 1 taken 37068 times.
1397171 if(clk==0)
8441 {
8442 37068 removearmos(x,y,ffcactivated);
8443 37068 }
8444
8445
2/2
✓ Branch 0 taken 1055988 times.
✓ Branch 1 taken 341183 times.
1397171 if(get_qr(qr_ENEMIESZAXIS))
8446 {
8447 341183 y=floor_y;
8448 341183 }
8449
8450
9/10
✓ Branch 0 taken 1282576 times.
✓ Branch 1 taken 114595 times.
✓ Branch 2 taken 1269012 times.
✓ Branch 3 taken 13564 times.
✓ Branch 4 taken 1269012 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 1257836 times.
✓ Branch 8 taken 12048 times.
✓ Branch 9 taken 21878 times.
1397171 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8451 {
8452
4/4
✓ Branch 0 taken 20260 times.
✓ Branch 1 taken 421148 times.
✓ Branch 2 taken 344884 times.
✓ Branch 3 taken 493422 times.
1279714 switch(misc)
8453 {
8454 case 0: // normal
8455
2/2
✓ Branch 0 taken 409927 times.
✓ Branch 1 taken 11221 times.
421148 if(!(zc_oldrand()%dmisc1))
8456 {
8457 11221 misc=1;
8458 11221 clk2=32;
8459 11221 }
8460
8461 421148 break;
8462
8463 case 1: // waiting to pounce
8464
2/2
✓ Branch 0 taken 324265 times.
✓ Branch 1 taken 20619 times.
344884 if(--clk2<=0)
8465 {
8466 20619 int32_t r=zc_oldrand();
8467 20619 misc=2;
8468 20619 step=0-(zslongToFix(dstep*100)); // initial speed
8469 20619 clk3=(r&1)+2; // left or right
8470 20619 clk2start=clk2=(r&31)+10; // flight time
8471
8472
2/2
✓ Branch 0 taken 18196 times.
✓ Branch 1 taken 2423 times.
20619 if(y<32) clk2+=2; // make them come down from top of screen
8473
8474
2/2
✓ Branch 0 taken 15702 times.
✓ Branch 1 taken 4917 times.
20619 if(y>112) clk2-=2; // make them go back up
8475
8476 20619 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8477 20619 }
8478
8479 344884 break;
8480
8481 case 2: // in flight
8482 493422 move(step);
8483
8484
2/2
✓ Branch 0 taken 234221 times.
✓ Branch 1 taken 259201 times.
493422 if(step>0) //going down
8485 {
8486
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 233589 times.
234221 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8487 {
8488 632 step=0-step;
8489 632 }
8490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233589 times.
233589 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8491 {
8492 step=0-step;
8493 }
8494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233589 times.
233589 else if(ispitfall(x+8,y+16))
8495 {
8496 step=0-step;
8497 }
8498
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 233542 times.
233589 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8499 {
8500 47 step=0-step;
8501 47 }
8502
2/2
✓ Branch 0 taken 233531 times.
✓ Branch 1 taken 11 times.
233542 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8503 {
8504 11 step=0-step;
8505 11 }
8506 234221 }
8507
2/2
✓ Branch 0 taken 15154 times.
✓ Branch 1 taken 244047 times.
259201 else if(step<0)
8508 {
8509
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 243609 times.
244047 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8510 {
8511 438 step=0-step;
8512 438 }
8513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243609 times.
243609 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8514 {
8515 step=0-step;
8516 }
8517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243609 times.
243609 else if(ispitfall(x+8,y))
8518 {
8519 step=0-step;
8520 }
8521
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 243588 times.
243609 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8522 {
8523 21 step=0-step;
8524 21 }
8525
2/2
✓ Branch 0 taken 243569 times.
✓ Branch 1 taken 19 times.
243588 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8526 {
8527 19 step=0-step;
8528 19 }
8529 244047 }
8530
8531
2/2
✓ Branch 0 taken 244152 times.
✓ Branch 1 taken 249270 times.
493422 if(clk3==left)
8532 {
8533
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 243877 times.
244152 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8534 {
8535 275 clk3^=1;
8536 275 }
8537
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 243871 times.
243877 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8538 {
8539 6 clk3^=1;
8540 6 }
8541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243871 times.
243871 else if(ispitfall(x,y+8))
8542 {
8543 clk3^=1;
8544 }
8545
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 243841 times.
243871 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8546 {
8547 30 clk3^=1;
8548 30 }
8549
2/2
✓ Branch 0 taken 243829 times.
✓ Branch 1 taken 12 times.
243841 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8550 {
8551 12 clk3^=1;
8552 12 }
8553 244152 }
8554 else
8555 {
8556
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 248994 times.
249270 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8557 {
8558 276 clk3^=1;
8559 276 }
8560
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 248982 times.
248994 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8561 {
8562 12 clk3^=1;
8563 12 }
8564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248982 times.
248982 else if(ispitfall(x+16,y+8))
8565 {
8566 clk3^=1;
8567 }
8568
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 248977 times.
248982 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8569 {
8570 5 clk3^=1;
8571 5 }
8572
2/2
✓ Branch 0 taken 248965 times.
✓ Branch 1 taken 12 times.
248977 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8573 {
8574 12 clk3^=1;
8575 12 }
8576 }
8577
8578 493422 --c;
8579
8580
4/4
✓ Branch 0 taken 151408 times.
✓ Branch 1 taken 342014 times.
✓ Branch 2 taken 320475 times.
✓ Branch 3 taken 172947 times.
493422 if(c<0 && step<zslongToFix(dstep*100))
8581 {
8582 172947 step+=zslongToFix(dmisc3*100);
8583 172947 }
8584
8585 493422 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8586
8587
2/2
✓ Branch 0 taken 492701 times.
✓ Branch 1 taken 721 times.
493422 if(x<=16-nb) clk3=right;
8588
8589
2/2
✓ Branch 0 taken 492430 times.
✓ Branch 1 taken 992 times.
493422 if(x>=224+nb) clk3=left;
8590
8591 493422 x += (clk3==left) ? -1 : 1;
8592
8593
4/4
✓ Branch 0 taken 29025 times.
✓ Branch 1 taken 464397 times.
✓ Branch 2 taken 10130 times.
✓ Branch 3 taken 454267 times.
493422 if((--clk2<=0 && y>=16-nb) || y>=144+nb)
8594 {
8595
4/4
✓ Branch 0 taken 1621 times.
✓ Branch 1 taken 17274 times.
✓ Branch 2 taken 1436 times.
✓ Branch 3 taken 185 times.
39155 if(y>=144+nb && get_qr(qr_ENEMIESZAXIS))
8596 {
8597 185 step=0-step;
8598 185 y--;
8599 185 }
8600
2/2
✓ Branch 0 taken 5794 times.
✓ Branch 1 taken 12916 times.
18710 else if(zc_oldrand()%dmisc2) //land and wait
8601 {
8602 12916 clk=misc=0;
8603 12916 } //land and jump again
8604 else
8605 {
8606 5794 misc=1;
8607 5794 clk2=0;
8608 }
8609 18895 }
8610
8611 473162 break;
8612 } // switch
8613 1259454 }
8614
8615
4/4
✓ Branch 0 taken 341183 times.
✓ Branch 1 taken 1058478 times.
✓ Branch 2 taken 231206 times.
✓ Branch 3 taken 109977 times.
1399661 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8616 {
8617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109977 times.
109977 if (moveflags & move_use_fake_z)
8618 {
8619 int32_t tempy = floor_y;
8620 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8621 floor_y = y;
8622 y=tempy-fakez;
8623 old_y = y;
8624 }
8625 else
8626 {
8627 109977 int32_t tempy = floor_y;
8628
6/6
✓ Branch 0 taken 55216 times.
✓ Branch 1 taken 54761 times.
✓ Branch 2 taken 104073 times.
✓ Branch 3 taken 5904 times.
✓ Branch 4 taken 50747 times.
✓ Branch 5 taken 53326 times.
109977 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8629 109977 floor_y = y;
8630 109977 y=tempy-z;
8631 109977 old_y = y;
8632 }
8633 109977 }
8634
8635
4/4
✓ Branch 0 taken 13564 times.
✓ Branch 1 taken 1386097 times.
✓ Branch 2 taken 2927 times.
✓ Branch 3 taken 10637 times.
1399661 if(stunclk && (clk&31)==1)
8636 10637 clk=0;
8637
8638 1399661 return enemy::animate(index);
8639 1426328 }
8640
8641 803206 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8642 {
8643
5/6
✓ Branch 0 taken 625928 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 625928 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 600737 times.
✓ Branch 5 taken 25191 times.
803206 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8644 25191 return;
8645
8646 778015 int32_t tempy=yofs;
8647 778015 int32_t fdiv = frate/4;
8648
1/2
✓ Branch 0 taken 778015 times.
✗ Branch 1 not taken.
778015 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8649
1/2
✓ Branch 0 taken 778015 times.
✗ Branch 1 not taken.
778015 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8650 778015 efrate:((clk>=(frate>>1))?1:0);
8651 778015 flip = 0;
8652 778015 shadowtile = wpnsbuf[spr_shadow].tile;
8653
8654
1/2
✓ Branch 0 taken 778015 times.
✗ Branch 1 not taken.
778015 if(get_qr(qr_NEWENEMYTILES))
8655 {
8656
2/2
✓ Branch 0 taken 575932 times.
✓ Branch 1 taken 202083 times.
778015 if(misc==0)
8657 {
8658 202083 shadowtile+=f2;
8659 202083 }
8660
2/2
✓ Branch 0 taken 254903 times.
✓ Branch 1 taken 321029 times.
575932 else if(misc!=1)
8661 321029 shadowtile+=2;
8662 778015 }
8663 else
8664 {
8665 if(misc==0)
8666 {
8667 shadowtile += f2 ? 1 : 0;
8668 }
8669 else if(misc!=1)
8670 {
8671 ++shadowtile;
8672 }
8673 }
8674
8675 778015 yofs+=8;
8676
8677
4/4
✓ Branch 0 taken 600737 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 339908 times.
✓ Branch 3 taken 260829 times.
778015 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8678 {
8679
6/6
✓ Branch 0 taken 134073 times.
✓ Branch 1 taken 126756 times.
✓ Branch 2 taken 243385 times.
✓ Branch 3 taken 17444 times.
✓ Branch 4 taken 123475 times.
✓ Branch 5 taken 119910 times.
260829 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8680 260829 }
8681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 778015 times.
778015 if(!shadow_overpit(this))
8682 778015 enemy::drawshadow(dest,translucent);
8683 778015 yofs=tempy;
8684 803206 }
8685
8686 2045360 void eTektite::draw(BITMAP *dest)
8687 {
8688 2045360 update_enemy_frame();
8689 2045360 enemy::draw(dest);
8690 2045360 }
8691
8692 730 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8693 730 {
8694
2/4
✓ Branch 0 taken 730 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 730 times.
✗ Branch 3 not taken.
730 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8695 730 superman=1;
8696 730 dir=8;
8697 730 hxofs=1000;
8698 730 mainguy=false;
8699 730 count_enemy=false;
8700
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
730 if (SIZEflags != 0) init_size_flags();;
8701 730 }
8702
8703 279897 bool eItemFairy::animate(int32_t index)
8704 {
8705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279897 times.
279897 if(switch_hooked) return enemy::animate(index);
8706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279897 times.
279897 if(dying)
8707 return Dead(index);
8708
8709 //if(clk>32)
8710 279897 misc=1;
8711 279897 bool w=watch;
8712 279897 watch=false;
8713 279897 variable_walk_8(misc?3:0,0,8,spw_floater);
8714 279897 watch=w;
8715
8716
2/2
✓ Branch 0 taken 1514 times.
✓ Branch 1 taken 278383 times.
279897 if(clk==0)
8717 {
8718 1514 removearmos(x,y,ffcactivated);
8719 1514 }
8720
8721 279897 return enemy::animate(index);
8722 279897 }
8723
8724 562150 void eItemFairy::draw(BITMAP *dest)
8725 {
8726 //these are here to bypass compiler warnings about unused arguments
8727 562150 dest=dest;
8728 562150 }
8729
8730 1825 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8731 1825 {
8732 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8733
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1825 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1825 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1825 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1825 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1825 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1825 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1825 times.
✗ Branch 19 not taken.
1825 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8734 1825 dir=8;
8735 1825 movestatus=1;
8736 1825 clk=0;
8737
1/2
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
1825 step=0;
8738 //nets+720;
8739
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1825 if (SIZEflags != 0) init_size_flags();;
8740 1825 }
8741
8742 520615 bool ePeahat::animate(int32_t index)
8743 {
8744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 520615 times.
520615 if(switch_hooked) return enemy::animate(index);
8745
2/4
✓ Branch 0 taken 520615 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 520615 times.
520615 if(fallclk||drownclk) return enemy::animate(index);
8746
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 520537 times.
520615 if(slide())
8747 {
8748 78 return false;
8749 }
8750
8751
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 519507 times.
520537 if(dying)
8752 1030 return Dead(index);
8753
8754
2/2
✓ Branch 0 taken 3083 times.
✓ Branch 1 taken 516424 times.
519507 if(clk==0)
8755 {
8756 3083 removearmos(x,y,ffcactivated);
8757 3083 }
8758
8759
4/4
✓ Branch 0 taken 516389 times.
✓ Branch 1 taken 3118 times.
✓ Branch 2 taken 253336 times.
✓ Branch 3 taken 263053 times.
519507 if(stunclk==0 && clk>96)
8760 263053 misc=1;
8761
8762
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
519507 if(!watch)
8763
2/2
✓ Branch 0 taken 171491 times.
✓ Branch 1 taken 345614 times.
517105 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8764
8765
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 419489 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
519507 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8766 {
8767
1/2
✓ Branch 0 taken 100018 times.
✗ Branch 1 not taken.
100018 if (moveflags & move_use_fake_z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8768 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8769 100018 }
8770
8771
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
519507 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8772 1634 superman=0;
8773 else
8774
2/2
✓ Branch 0 taken 9811 times.
✓ Branch 1 taken 508062 times.
517873 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8775 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8776
2/2
✓ Branch 0 taken 264937 times.
✓ Branch 1 taken 254570 times.
519507 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8777 {
8778
2/2
✓ Branch 0 taken 261822 times.
✓ Branch 1 taken 3115 times.
264937 if ( stunclk ) --stunclk;
8779 264937 }
8780 254570 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8781 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8782
8783
8784
2/2
✓ Branch 0 taken 519267 times.
✓ Branch 1 taken 240 times.
519507 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8785
8786 519507 return enemy::animate(index);
8787 520615 }
8788
8789 334520 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8790 {
8791 334520 int32_t tempy=yofs;
8792 334520 flip = 0;
8793 334520 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8794
8795
2/2
✓ Branch 0 taken 88089 times.
✓ Branch 1 taken 246431 times.
334520 if(!get_qr(qr_ENEMIESZAXIS))
8796 {
8797 246431 yofs+=8;
8798 246431 yofs+=int32_t(step/zslongToFix(dstep*10));
8799 246431 }
8800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334520 times.
334520 if(!shadow_overpit(this))
8801 334520 enemy::drawshadow(dest,translucent);
8802 334520 yofs=tempy;
8803 334520 }
8804
8805 1144330 void ePeahat::draw(BITMAP *dest)
8806 {
8807 1144330 update_enemy_frame();
8808 1144330 enemy::draw(dest);
8809 1144330 }
8810
8811 4136 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8812 {
8813 4136 int32_t wpnId = w->id;
8814 4136 int32_t enemyHitWeapon = w->parentitem;
8815
8816
3/6
✓ Branch 0 taken 4136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4136 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4136 times.
4136 if(dying || clk<0 || hclk>0)
8817 return 0;
8818
8819
4/4
✓ Branch 0 taken 3381 times.
✓ Branch 1 taken 755 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 206 times.
4380 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8820 // fire boomerang, for nailing peahats
8821
4/6
✓ Branch 0 taken 3381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3137 times.
✓ Branch 3 taken 244 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 244 times.
3381 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8822 3343 return 0;
8823
8824 // Time for a kludge...
8825 793 int32_t s = superman;
8826 793 superman = 0;
8827 793 int32_t ret = enemy::takehit(w,realweap);
8828 793 superman = s;
8829
8830 // Anyway...
8831
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 192 times.
793 if(stunclk == 160)
8832 {
8833 192 clk2=0;
8834 192 movestatus=0;
8835 192 misc=0;
8836 192 clk=0;
8837 192 step=0;
8838 192 }
8839
8840 793 return ret;
8841 4136 }
8842
8843 // auomatically kill off enemy (for rooms with ringleaders)
8844 void ePeahat::kickbucket()
8845 {
8846 hp=-1000; // don't call death_sfx()
8847 }
8848
8849 3942 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8850 3942 {
8851 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8852
2/2
✓ Branch 0 taken 1795 times.
✓ Branch 1 taken 2147 times.
3942 if(dmisc1==0)
8853 {
8854 2147 misc=-1; //Line of Sight leevers
8855 2147 clk-=16;
8856 2147 }
8857 3942 clk3 = 0;
8858 //nets+1460;
8859 3942 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8860 3942 submerged = false;
8861
1/4
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3942 if (SIZEflags != 0) init_size_flags();;
8862 3942 }
8863
8864 923 bool eLeever::isSubmerged() const
8865 {
8866 923 Z_scripterrlog("misc is: %d\n", misc);
8867 923 return misc <= 0;
8868
8869 }
8870
8871 1018478 bool eLeever::animate(int32_t index)
8872 {
8873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1018478 times.
1018478 if(switch_hooked) return enemy::animate(index);
8874
3/4
✓ Branch 0 taken 1018123 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1018123 times.
1018478 if(fallclk||drownclk)
8875 {
8876 355 return enemy::animate(index);
8877 }
8878
2/2
✓ Branch 0 taken 31552 times.
✓ Branch 1 taken 986571 times.
1018123 if(dying)
8879 31552 return Dead(index);
8880
8881
2/2
✓ Branch 0 taken 941601 times.
✓ Branch 1 taken 44970 times.
986571 if(clk==0)
8882 {
8883 44970 removearmos(x,y,ffcactivated);
8884 44970 }
8885
8886
4/4
✓ Branch 0 taken 816947 times.
✓ Branch 1 taken 169624 times.
✓ Branch 2 taken 5265 times.
✓ Branch 3 taken 811682 times.
986571 if(clk>=0 && !slide())
8887 {
8888 // switch(d->misc1)
8889
2/2
✓ Branch 0 taken 337868 times.
✓ Branch 1 taken 473814 times.
811682 switch(dmisc1)
8890 {
8891 case 0: //line of sight
8892 case 2:
8893
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 124459 times.
✓ Branch 2 taken 49109 times.
✓ Branch 3 taken 35464 times.
✓ Branch 4 taken 15780 times.
✓ Branch 5 taken 101784 times.
✓ Branch 6 taken 4365 times.
✓ Branch 7 taken 6907 times.
337868 switch(misc) //is this leever active
8894 {
8895 case -1: //submerged
8896 {
8897
4/6
✓ Branch 0 taken 6382 times.
✓ Branch 1 taken 118077 times.
✓ Branch 2 taken 6382 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6382 times.
124459 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
8898
4/4
✓ Branch 0 taken 10299 times.
✓ Branch 1 taken 114160 times.
✓ Branch 2 taken 10261 times.
✓ Branch 3 taken 38 times.
124459 if((dmisc1==2)&&(zc_oldrand()&255))
8899 {
8900 10261 break;
8901 }
8902
8903 114198 int32_t active=0;
8904
8905
2/2
✓ Branch 0 taken 783342 times.
✓ Branch 1 taken 114198 times.
897540 for(int32_t i=0; i<guys.Count(); i++)
8906 {
8907
4/4
✓ Branch 0 taken 627294 times.
✓ Branch 1 taken 156048 times.
✓ Branch 2 taken 401598 times.
✓ Branch 3 taken 225696 times.
783342 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
8908 {
8909 225696 ++active;
8910 225696 }
8911 783342 }
8912
8913
2/2
✓ Branch 0 taken 112327 times.
✓ Branch 1 taken 1871 times.
114198 if(active<((dmisc1==2)?1:2))
8914 {
8915 1871 misc=0; //activate this one
8916 1871 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
8917 1871 }
8918 }
8919 114198 break;
8920
8921 case 0:
8922 {
8923
8924
4/6
✓ Branch 0 taken 11920 times.
✓ Branch 1 taken 37189 times.
✓ Branch 2 taken 11920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11920 times.
49109 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
8925 {
8926 misc=1;
8927 clk2=0;
8928 }
8929
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 49052 times.
49109 else if (clk3<=0)
8930 {
8931 57 misc = -1;
8932 57 break;
8933 }
8934 49052 int32_t s=0;
8935
8936
2/2
✓ Branch 0 taken 273250 times.
✓ Branch 1 taken 49052 times.
322302 for(int32_t i=0; i<guys.Count(); i++)
8937 {
8938
4/4
✓ Branch 0 taken 164314 times.
✓ Branch 1 taken 108936 times.
✓ Branch 2 taken 156432 times.
✓ Branch 3 taken 7882 times.
273250 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
8939 {
8940 7882 ++s;
8941 7882 }
8942 273250 }
8943
8944
2/2
✓ Branch 0 taken 7882 times.
✓ Branch 1 taken 41170 times.
49052 if(s>0)
8945 {
8946 7882 break;
8947 }
8948
8949 41170 int32_t d2=zc_oldrand()&1;
8950
8951
2/2
✓ Branch 0 taken 14509 times.
✓ Branch 1 taken 26661 times.
41170 if(HeroDir()>=left)
8952 {
8953 26661 d2+=2;
8954 26661 }
8955
8956
4/4
✓ Branch 0 taken 39722 times.
✓ Branch 1 taken 1448 times.
✓ Branch 2 taken 662 times.
✓ Branch 3 taken 39060 times.
41170 if(canplace(d2) || canplace(d2^1))
8957 {
8958 2110 misc=1;
8959 2110 clk2=0;
8960 2110 clk=0;
8961 2110 }
8962 }
8963 41170 break;
8964
8965 case 1:
8966
8967
7/8
✓ Branch 0 taken 33397 times.
✓ Branch 1 taken 2067 times.
✓ Branch 2 taken 3596 times.
✓ Branch 3 taken 29801 times.
✓ Branch 4 taken 3596 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 3595 times.
35464 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
8968
8969 35464 break;
8970
8971 case 2:
8972
8973
7/8
✓ Branch 0 taken 13865 times.
✓ Branch 1 taken 1915 times.
✓ Branch 2 taken 1503 times.
✓ Branch 3 taken 12362 times.
✓ Branch 4 taken 1503 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1502 times.
15780 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
8974
8975 15780 break;
8976
8977 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
8978 case 3:
8979
8980
5/6
✓ Branch 0 taken 98195 times.
✓ Branch 1 taken 3589 times.
✓ Branch 2 taken 98195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2727 times.
✓ Branch 5 taken 95468 times.
101784 if(stunclk || frozenclock || watch) break;
8981
8982
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 95326 times.
95468 if(scored) dir^=1;
8983
8984
2/2
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 94963 times.
95468 if(!canmove(dir,false)) misc=4;
8985 94963 else move(zslongToFix(dstep*100));
8986
8987 95468 break;
8988
8989 case 4:
8990
4/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 3755 times.
✓ Branch 2 taken 610 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 610 times.
4365 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
8991
2/2
✓ Branch 0 taken 3897 times.
✓ Branch 1 taken 468 times.
4365 if(--clk2<=16)
8992 {
8993 468 misc=5;
8994 468 clk=8;
8995 468 }
8996
8997 4365 break;
8998
8999 case 5:
9000
5/6
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 5897 times.
✓ Branch 2 taken 1010 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1009 times.
6907 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
9001
2/2
✓ Branch 0 taken 6497 times.
✓ Branch 1 taken 410 times.
6907 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
9002
9003 6907 break;
9004 } // switch(misc)
9005
9006 337868 break;
9007
9008 default: //random
9009 // step=d->misc3/100.0;
9010
9011 473814 step=zslongToFix(dmisc3*100);
9012
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
473814 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
9013 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9014 {
9015 if (clk2 < 48) clk2+=2;
9016 if (clk2 >= 300) clk2-=2;
9017 }
9018
9019
2/2
✓ Branch 0 taken 60840 times.
✓ Branch 1 taken 412974 times.
473814 if(clk2<32) misc=1;
9020
2/2
✓ Branch 0 taken 30244 times.
✓ Branch 1 taken 382730 times.
412974 else if(clk2<48) misc=2;
9021
2/2
✓ Branch 0 taken 289541 times.
✓ Branch 1 taken 93189 times.
382730 else if(clk2<300)
9022 {
9023 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
9024 {
9025 fix_coords();
9026 }*/
9027 289541 misc=3;
9028 289541 step = zslongToFix(dstep*100);
9029 289541 }
9030
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 84180 times.
93189 else if(clk2<316) misc=2;
9031
2/2
✓ Branch 0 taken 43755 times.
✓ Branch 1 taken 40425 times.
84180 else if(clk2<412) misc=1;
9032
2/2
✓ Branch 0 taken 40151 times.
✓ Branch 1 taken 274 times.
40425 else if(clk2<540)
9033 {
9034 40151 misc=0;
9035 40151 step=0;
9036 40151 }
9037 274 else clk2=0;
9038
9039
2/2
✓ Branch 0 taken 471961 times.
✓ Branch 1 taken 1853 times.
473814 if(clk2==48) clk=0;
9040
9041 // variable_walk(d->rate, d->homing, 0);
9042 473814 variable_walk(rate, homing, 0);
9043 473814 } // switch(dmisc1)
9044 811682 }
9045
9046 986571 hxofs=(misc>=2)?0:1000;
9047 986571 return enemy::animate(index);
9048 1018478 }
9049
9050 80892 bool eLeever::canplace(int32_t d2)
9051 {
9052 80892 int32_t nx=HeroX();
9053 80892 int32_t ny=HeroY();
9054
9055
2/2
✓ Branch 0 taken 28492 times.
✓ Branch 1 taken 52400 times.
80892 if(d2<left) ny&=0xF0;
9056 52400 else nx&=0xF0;
9057
9058
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14174 times.
✓ Branch 2 taken 14318 times.
✓ Branch 3 taken 26181 times.
✓ Branch 4 taken 26219 times.
80892 switch(d2)
9059 {
9060 // case up: ny-=((d->misc1==0)?32:48); break;
9061 // case down: ny+=((d->misc1==0)?32:48); if(ny-HeroY()<32) ny+=((d->misc1==0)?16:0); break;
9062 // case left: nx-=((d->misc1==0)?32:48); break;
9063 // case right: nx+=((d->misc1==0)?32:48); if(nx-HeroX()<32) nx+=((d->misc1==0)?16:0); break;
9064 case up:
9065
2/2
✓ Branch 0 taken 14144 times.
✓ Branch 1 taken 30 times.
14174 ny-=((dmisc1==0||dmisc1==2)?32:48);
9066 14174 break;
9067
9068 case down:
9069
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 14284 times.
14318 ny+=((dmisc1==0||dmisc1==2)?32:48);
9070
9071
4/4
✓ Branch 0 taken 10086 times.
✓ Branch 1 taken 4232 times.
✓ Branch 2 taken 10075 times.
✓ Branch 3 taken 11 times.
14318 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9072
9073 14318 break;
9074
9075 case left:
9076
2/2
✓ Branch 0 taken 25528 times.
✓ Branch 1 taken 653 times.
26181 nx-=((dmisc1==0||dmisc1==2)?32:48);
9077 26181 break;
9078
9079 case right:
9080
2/2
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 25573 times.
26219 nx+=((dmisc1==0||dmisc1==2)?32:48);
9081
9082
4/4
✓ Branch 0 taken 19151 times.
✓ Branch 1 taken 7068 times.
✓ Branch 2 taken 18549 times.
✓ Branch 3 taken 602 times.
26219 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9083
9084 26219 break;
9085 }
9086
9087
4/4
✓ Branch 0 taken 20428 times.
✓ Branch 1 taken 60464 times.
✓ Branch 2 taken 9001 times.
✓ Branch 3 taken 11427 times.
80892 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9088 69465 return false;
9089
9090
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 10563 times.
11427 if(d2>=left)
9091
4/4
✓ Branch 0 taken 5025 times.
✓ Branch 1 taken 5538 times.
✓ Branch 2 taken 9317 times.
✓ Branch 3 taken 1246 times.
10563 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9092 9317 return false;
9093
9094 2110 x=nx;
9095 2110 y=ny;
9096 2110 dir=d2^1;
9097 2110 return true;
9098 80892 }
9099
9100 1024382 void eLeever::draw(BITMAP *dest)
9101 {
9102 // cs=d->cset;
9103 1024382 cs=dcset;
9104 1024382 update_enemy_frame();
9105
3/4
✓ Branch 0 taken 1024027 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1024027 times.
1024382 if(!fallclk&&!drownclk)
9106 {
9107
2/2
✓ Branch 0 taken 637088 times.
✓ Branch 1 taken 386939 times.
1024027 switch(misc)
9108 {
9109 case -1:
9110 case 0:
9111 386939 return;
9112 }
9113 637088 }
9114
9115 637443 enemy::draw(dest);
9116 1024382 }
9117
9118 998 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9119 998 {
9120 998 hashero=false;
9121 //nets+1000;
9122
1/4
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
998 if (SIZEflags != 0) init_size_flags();;
9123 998 }
9124
9125 504762 bool eWallM::animate(int32_t index)
9126 {
9127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504762 times.
504762 if(switch_hooked) return enemy::animate(index);
9128
2/4
✓ Branch 0 taken 504762 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 504762 times.
504762 if(fallclk||drownclk)
9129 {
9130 return enemy::animate(index);
9131 }
9132
2/2
✓ Branch 0 taken 9856 times.
✓ Branch 1 taken 494906 times.
504762 if(dying)
9133 9856 return Dead(index);
9134
9135
2/2
✓ Branch 0 taken 463930 times.
✓ Branch 1 taken 30976 times.
494906 if(clk==0)
9136 {
9137 30976 removearmos(x,y,ffcactivated);
9138 30976 }
9139
9140 494906 hxofs=1000;
9141
2/2
✓ Branch 0 taken 117732 times.
✓ Branch 1 taken 377174 times.
494906 if(misc==0) //inside wall, ready to spawn?
9142 {
9143
4/4
✓ Branch 0 taken 228512 times.
✓ Branch 1 taken 148662 times.
✓ Branch 2 taken 16723 times.
✓ Branch 3 taken 211789 times.
377174 if(frame-wallm_load_clk>80 && clk>=0)
9144 {
9145 211789 int32_t wall=hero_on_wall();
9146 211789 int32_t wallm_cnt=0;
9147
9148
2/2
✓ Branch 0 taken 1670618 times.
✓ Branch 1 taken 211789 times.
1882407 for(int32_t i=0; i<guys.Count(); i++)
9149
2/2
✓ Branch 0 taken 657527 times.
✓ Branch 1 taken 1013091 times.
2683709 if(((enemy*)guys.spr(i))->family==eeWALLM)
9150 {
9151 1013091 int32_t m=((enemy*)guys.spr(i))->misc;
9152
9153
4/4
✓ Branch 0 taken 50104 times.
✓ Branch 1 taken 962987 times.
✓ Branch 2 taken 36738 times.
✓ Branch 3 taken 13366 times.
1013091 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9154 {
9155 13366 ++wallm_cnt;
9156 13366 }
9157 1013091 }
9158
9159
2/2
✓ Branch 0 taken 210948 times.
✓ Branch 1 taken 841 times.
211789 if(wall>0)
9160 {
9161 841 --wall;
9162 841 misc=1; //emerging from the wall?
9163 841 clk2=0;
9164 841 clk3=wall^1;
9165 841 wallm_load_clk=frame;
9166
9167
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 327 times.
841 if(wall<=down)
9168 {
9169
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 423 times.
514 if(HeroDir()==left)
9170 91 dir=right;
9171 else
9172 423 dir=left;
9173 514 }
9174 else
9175 {
9176
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 261 times.
327 if(HeroDir()==up)
9177 66 dir=down;
9178 else
9179 261 dir=up;
9180 }
9181
9182
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 223 times.
✓ Branch 4 taken 104 times.
841 switch(wall)
9183 {
9184 case up:
9185 231 y=0;
9186 231 break;
9187
9188 case down:
9189 283 y=160;
9190 283 break;
9191
9192 case left:
9193 223 x=0;
9194 223 break;
9195
9196 case right:
9197 104 x=240;
9198 104 break;
9199 }
9200
9201
9202
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 91 times.
841 switch(dir)
9203 {
9204 case up:
9205 261 y=(HeroY()+48-(wallm_cnt&1)*12);
9206 261 flip=wall&1;
9207 261 break;
9208
9209 case down:
9210 66 y=(HeroY()-48+(wallm_cnt&1)*12);
9211 66 flip=((wall&1)^1)+2;
9212 66 break;
9213
9214 case left:
9215 423 x=(HeroX()+48-(wallm_cnt&1)*12);
9216 423 flip=(wall==up?2:0)+1;
9217 423 break;
9218
9219 case right:
9220 91 x=(HeroX()-48+(wallm_cnt&1)*12);
9221 91 flip=(wall==up?2:0);
9222 91 break;
9223 }
9224
9225 841 }
9226 211789 }
9227 377174 }
9228 else
9229 117732 wallm_crawl();
9230
9231 494906 return enemy::animate(index);
9232 504762 }
9233
9234 117732 void eWallM::wallm_crawl()
9235 {
9236 117732 bool w=watch;
9237 117732 hxofs=0;
9238
9239
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 116922 times.
117732 if(slide())
9240 {
9241 810 return;
9242 }
9243
9244 // if(dying || watch || (!hashero && stunclk))
9245
6/8
✓ Branch 0 taken 116922 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115593 times.
✓ Branch 3 taken 1329 times.
✓ Branch 4 taken 101047 times.
✓ Branch 5 taken 14546 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 101047 times.
116922 if(dying || (!hashero && ( stunclk || frozenclock )))
9246 {
9247 14546 return;
9248 }
9249
9250 102376 watch=false;
9251 102376 ++clk2;
9252 // Misc1: slightly different movement
9253 102376 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9254
9255 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102376 times.
102376 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9257
5/6
✓ Branch 0 taken 6217 times.
✓ Branch 1 taken 96159 times.
✓ Branch 2 taken 4491 times.
✓ Branch 3 taken 1726 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4491 times.
102376 if(w&&misc>=3&&misc<=5)
9258 {
9259 4491 --clk2;
9260 4491 }
9261
9262
4/4
✓ Branch 0 taken 39396 times.
✓ Branch 1 taken 52852 times.
✓ Branch 2 taken 9984 times.
✓ Branch 3 taken 144 times.
102376 switch(misc)
9263 {
9264 case 1:
9265 case 2:
9266 52852 zc_swap(dir,clk3);
9267 52852 move(step);
9268 52852 zc_swap(dir,clk3);
9269 52852 break;
9270
9271 case 3:
9272 case 4:
9273 case 5:
9274
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 34905 times.
39396 if(w)
9275 {
9276 4491 watch=w;
9277 4491 return;
9278 }
9279
9280 34905 move(step);
9281 34905 break;
9282
9283 case 6:
9284 case 7:
9285 9984 zc_swap(dir,clk3);
9286 9984 dir^=1;
9287 9984 move(step);
9288 9984 dir^=1;
9289 9984 zc_swap(dir,clk3);
9290 9984 break;
9291
9292 default:
9293 144 misc=0;
9294 144 break;
9295 }
9296
9297 97885 watch=w;
9298 117732 }
9299
9300 9 void eWallM::grabhero()
9301 {
9302 9 hashero=true;
9303 9 superman=1;
9304 9 }
9305
9306 507147 void eWallM::draw(BITMAP *dest)
9307 {
9308 507147 dummy_bool[1]=hashero;
9309 507147 update_enemy_frame();
9310
9311
4/6
✓ Branch 0 taken 377966 times.
✓ Branch 1 taken 129181 times.
✓ Branch 2 taken 377966 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 377966 times.
507147 if(misc>0 || fallclk||drownclk)
9312 {
9313 129181 masked_draw(dest,16,playing_field_offset+16,224,144);
9314 129181 }
9315
9316 // enemy::draw(dest);
9317 // tile = clk&8 ? 128:129;
9318 507147 }
9319
9320 bool eWallM::isSubmerged() const
9321 {
9322 return ( !misc );
9323 }
9324
9325 1600 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9326 1600 {
9327
1/2
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
1600 ox=x; //original x
9328
1/2
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
1600 oy=y; //original y
9329
2/2
✓ Branch 0 taken 1474 times.
✓ Branch 1 taken 126 times.
1600 if(get_qr(qr_TRAPPOSFIX))
9330 {
9331
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9332 126 }
9333
9334 1600 mainguy=false;
9335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
1600 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9336 //nets+420;
9337 1600 dummy_int[1]=0;
9338
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1600 if (SIZEflags != 0) init_size_flags();;
9339 1600 }
9340
9341 1036935 bool eTrap::animate(int32_t index)
9342 {
9343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1036935 times.
1036935 if(switch_hooked) return enemy::animate(index);
9344
2/4
✓ Branch 0 taken 1036935 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1036935 times.
1036935 if(fallclk||drownclk) return enemy::animate(index);
9345
2/2
✓ Branch 0 taken 1015341 times.
✓ Branch 1 taken 21594 times.
1036935 if(clk<0)
9346 21594 return enemy::animate(index);
9347
9348
2/2
✓ Branch 0 taken 951124 times.
✓ Branch 1 taken 64217 times.
1015341 if(clk==0)
9349 {
9350 64217 removearmos(x,y,ffcactivated);
9351 64217 }
9352
9353
2/2
✓ Branch 0 taken 317997 times.
✓ Branch 1 taken 697344 times.
1015341 if(misc==0) // waiting
9354 {
9355 697344 ox = x;
9356 697344 oy = y;
9357 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9358 697344 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9359
9360
4/4
✓ Branch 0 taken 240663 times.
✓ Branch 1 taken 456681 times.
✓ Branch 2 taken 133176 times.
✓ Branch 3 taken 107487 times.
697344 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9361 {
9362 107487 dir=down;
9363 107487 }
9364
4/4
✓ Branch 0 taken 391518 times.
✓ Branch 1 taken 198339 times.
✓ Branch 2 taken 133176 times.
✓ Branch 3 taken 258342 times.
589857 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9365 {
9366 258342 dir=right;
9367 258342 }
9368
4/4
✓ Branch 0 taken 210645 times.
✓ Branch 1 taken 120870 times.
✓ Branch 2 taken 133176 times.
✓ Branch 3 taken 77469 times.
331515 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9369 {
9370 77469 dir=up;
9371 77469 }
9372 else
9373 {
9374 254046 dir=left;
9375 }
9376
9377 697344 int32_t d2=lined_up(15,true);
9378
9379
4/4
✓ Branch 0 taken 267045 times.
✓ Branch 1 taken 430299 times.
✓ Branch 2 taken 1111152 times.
✓ Branch 3 taken 413808 times.
1091329 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9380
2/2
✓ Branch 0 taken 232556 times.
✓ Branch 1 taken 190596 times.
413808 ((d2>down) && (dmisc1==2)) ||
9381
2/2
✓ Branch 0 taken 187069 times.
✓ Branch 1 taken 60611 times.
190596 ((d2>right) && (!dmisc1)) ||
9382
2/2
✓ Branch 0 taken 393985 times.
✓ Branch 1 taken 146305 times.
247680 ((d2<l_up) && (dmisc1==4)) ||
9383
3/4
✓ Branch 0 taken 393985 times.
✓ Branch 1 taken 247680 times.
✓ Branch 2 taken 393985 times.
✗ Branch 3 not taken.
146305 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9384
3/4
✓ Branch 0 taken 393985 times.
✓ Branch 1 taken 146305 times.
✓ Branch 2 taken 393985 times.
✗ Branch 3 not taken.
247680 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9385 {
9386 2525663 d2=-1;
9387 2525663 }
9388
9389
4/4
✓ Branch 0 taken 20700 times.
✓ Branch 1 taken 428964 times.
✓ Branch 2 taken 18593 times.
✓ Branch 3 taken 2107 times.
449664 if(d2!=-1 && trapmove(d2))
9390 {
9391 2107 dir=d2;
9392 2107 misc=1;
9393 2107 clk2=(dir==down)?3:0;
9394 2107 }
9395 449664 }
9396
9397
2/2
✓ Branch 0 taken 678404 times.
✓ Branch 1 taken 89257 times.
767661 if(misc==1) // charging
9398 {
9399 89257 clk2=(clk2+1)&3;
9400 89257 step=(clk2==3)?1:2;
9401
9402
4/4
✓ Branch 0 taken 88461 times.
✓ Branch 1 taken 796 times.
✓ Branch 2 taken 1105 times.
✓ Branch 3 taken 87356 times.
89257 if(!trapmove(dir) || clip())
9403 {
9404 1901 misc=2;
9405
9406
1/2
✓ Branch 0 taken 1901 times.
✗ Branch 1 not taken.
1901 if(dir<l_up)
9407 {
9408 1901 dir=dir^1;
9409 1901 }
9410 else
9411 {
9412 dir=dir^3;
9413 }
9414 1901 }
9415 else
9416 {
9417 87356 sprite::move(step);
9418 }
9419 89257 }
9420
9421
2/2
✓ Branch 0 taken 534913 times.
✓ Branch 1 taken 232748 times.
767661 if(misc==2) // retreating
9422 {
9423 232748 step=(++clk2&1)?1:0;
9424
9425
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 39011 times.
✓ Branch 2 taken 80505 times.
✓ Branch 3 taken 29129 times.
✓ Branch 4 taken 84103 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
232748 switch(dir)
9426 {
9427 case up:
9428
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 38739 times.
39011 if(int32_t(y)<=oy) goto trap_rest;
9429 38739 else sprite::move(step);
9430
9431 38739 break;
9432
9433 case left:
9434
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 80117 times.
80505 if(int32_t(x)<=ox) goto trap_rest;
9435 80117 else sprite::move(step);
9436
9437 80117 break;
9438
9439 case down:
9440
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 28905 times.
29129 if(int32_t(y)>=oy) goto trap_rest;
9441 28905 else sprite::move(step);
9442
9443 28905 break;
9444
9445 case right:
9446
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 83672 times.
84103 if(int32_t(x)>=ox) goto trap_rest;
9447 83672 else sprite::move(step);
9448
9449 83672 break;
9450
9451 case l_up:
9452 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9453 else sprite::move(step);
9454
9455 break;
9456
9457 case r_up:
9458 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9459 else sprite::move(step);
9460
9461 break;
9462
9463 case l_down:
9464 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9465 else sprite::move(step);
9466
9467 break;
9468
9469 case r_down:
9470 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9471 else sprite::move(step);
9472
9473 break;
9474 trap_rest:
9475 {
9476 1315 x=ox;
9477 1315 y=oy;
9478 1315 misc=0;
9479 }
9480 1315 }
9481 232748 }
9482
9483 767661 return enemy::animate(index);
9484 789255 }
9485
9486 109957 bool eTrap::trapmove(int32_t ndir)
9487 {
9488
2/2
✓ Branch 0 taken 80193 times.
✓ Branch 1 taken 29764 times.
109957 if(get_qr(qr_MEANTRAPS))
9489 {
9490
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 78853 times.
80193 if(tmpscr->flags2&fFLOATTRAPS)
9491 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9492
9493 78853 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9494 }
9495
9496
6/6
✓ Branch 0 taken 14672 times.
✓ Branch 1 taken 15092 times.
✓ Branch 2 taken 7198 times.
✓ Branch 3 taken 7474 times.
✓ Branch 4 taken 2468 times.
✓ Branch 5 taken 4730 times.
29764 if(oy==80 && !(ndir==left || ndir == right))
9497 4730 return false;
9498
9499
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25034 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25034 if(ox==128 && !(ndir==up || ndir==down))
9500 return false;
9501
9502
3/4
✓ Branch 0 taken 7496 times.
✓ Branch 1 taken 17538 times.
✓ Branch 2 taken 7496 times.
✗ Branch 3 not taken.
25034 if(oy<80 && ndir==up)
9503 return false;
9504
9505
3/4
✓ Branch 0 taken 7596 times.
✓ Branch 1 taken 17438 times.
✓ Branch 2 taken 7596 times.
✗ Branch 3 not taken.
25034 if(oy>80 && ndir==down)
9506 return false;
9507
9508
4/4
✓ Branch 0 taken 14455 times.
✓ Branch 1 taken 10579 times.
✓ Branch 2 taken 9733 times.
✓ Branch 3 taken 4722 times.
25034 if(ox<128 && ndir==left)
9509 4722 return false;
9510
9511
4/4
✓ Branch 0 taken 10579 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 9866 times.
✓ Branch 3 taken 713 times.
20312 if(ox>128 && ndir==right)
9512 713 return false;
9513
9514
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 4067 times.
✓ Branch 3 taken 5666 times.
✓ Branch 4 taken 4067 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy<80 && ndir==l_up)
9515 return false;
9516
9517
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 3911 times.
✓ Branch 3 taken 5822 times.
✓ Branch 4 taken 3911 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy>80 && ndir==l_down)
9518 return false;
9519
9520
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3429 times.
✓ Branch 3 taken 6437 times.
✓ Branch 4 taken 3429 times.
✗ Branch 5 not taken.
19599 if(ox>128 && oy<80 && ndir==r_up)
9521 return false;
9522
9523
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 6181 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3685 times.
19599 if(ox>128 && oy>80 && ndir==r_down)
9524 return false;
9525
9526 19599 return true;
9527 109957 }
9528
9529 88461 bool eTrap::clip()
9530 {
9531
2/2
✓ Branch 0 taken 43022 times.
✓ Branch 1 taken 45439 times.
88461 if(get_qr(qr_MEANPLACEDTRAPS))
9532 {
9533
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
✓ Branch 2 taken 8656 times.
✓ Branch 3 taken 15895 times.
✓ Branch 4 taken 15096 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
45439 switch(dir)
9534 {
9535 case up:
9536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
5792 if(y<=0) return true;
9537
9538 5792 break;
9539
9540 case down:
9541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8656 times.
8656 if(y>=160) return true;
9542
9543 8656 break;
9544
9545 case left:
9546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15895 times.
15895 if(x<=0) return true;
9547
9548 15895 break;
9549
9550 case right:
9551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15096 times.
15096 if(x>=240) return true;
9552
9553 15096 break;
9554
9555 case l_up:
9556 if(y<=0||x<=0) return true;
9557
9558 break;
9559
9560 case l_down:
9561 if(y>=160||x<=0) return true;
9562
9563 break;
9564
9565 case r_up:
9566 if(y<=0||x>=240) return true;
9567
9568 break;
9569
9570 case r_down:
9571 if(y>=160||x>=240) return true;
9572
9573 break;
9574 }
9575
9576 45439 return false;
9577 }
9578 else
9579 {
9580
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 4882 times.
✓ Branch 2 taken 5449 times.
✓ Branch 3 taken 16755 times.
✓ Branch 4 taken 15936 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
43022 switch(dir)
9581 {
9582 case up:
9583
4/4
✓ Branch 0 taken 4828 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 4641 times.
✓ Branch 3 taken 187 times.
4882 if(oy>80 && y<=86) return true;
9584
9585 4695 break;
9586
9587 case down:
9588
4/4
✓ Branch 0 taken 5368 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 5172 times.
✓ Branch 3 taken 196 times.
5449 if(oy<80 && y>=80) return true;
9589
9590 5253 break;
9591
9592 case left:
9593
4/4
✓ Branch 0 taken 16665 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 16286 times.
✓ Branch 3 taken 379 times.
16755 if(ox>128 && x<=124) return true;
9594
9595 16376 break;
9596
9597 case right:
9598
4/4
✓ Branch 0 taken 15855 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 15512 times.
✓ Branch 3 taken 343 times.
15936 if(ox<120 && x>=116) return true;
9599
9600 15593 break;
9601
9602 case l_up:
9603 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9604
9605 break;
9606
9607 case l_down:
9608 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9609
9610 break;
9611
9612 case r_up:
9613 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9614
9615 break;
9616
9617 case r_down:
9618 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9619
9620 break;
9621 }
9622
9623 41917 return false;
9624 }
9625 88461 }
9626
9627 1043991 void eTrap::draw(BITMAP *dest)
9628 {
9629 1043991 update_enemy_frame();
9630 1043991 enemy::draw(dest);
9631 1043991 }
9632
9633 5705 int32_t eTrap::takehit(weapon*,weapon*)
9634 {
9635 5705 return 0;
9636 }
9637
9638 832 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9639 832 {
9640 832 lasthit=-1;
9641 832 lasthitclk=0;
9642 832 mainguy=false;
9643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9644
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 step=2;
9645
3/6
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 399 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9646 {
9647
2/4
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399 times.
✗ Branch 3 not taken.
399 dir=(x<=112)?right:left;
9648 399 }
9649 else
9650 {
9651
2/4
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 433 times.
✗ Branch 3 not taken.
433 dir=(y<=72)?down:up;
9652 }
9653
9654
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 72 times.
832 if(get_qr(qr_TRAPPOSFIX))
9655 {
9656
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9657 72 }
9658
9659 //nets+((id==eTRAP_LR)?540:520);
9660 832 dummy_int[1]=0;
9661
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
832 if (SIZEflags != 0) init_size_flags();;
9662 832 }
9663
9664 346559 bool eTrap2::animate(int32_t index)
9665 {
9666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 346559 times.
346559 if(switch_hooked) return enemy::animate(index);
9667
2/4
✓ Branch 0 taken 346559 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 346559 times.
346559 if(fallclk||drownclk) return enemy::animate(index);
9668
2/2
✓ Branch 0 taken 335533 times.
✓ Branch 1 taken 11026 times.
346559 if(clk<0)
9669 11026 return enemy::animate(index);
9670
9671
2/2
✓ Branch 0 taken 21385 times.
✓ Branch 1 taken 314148 times.
335533 if(clk==0)
9672 {
9673 21385 removearmos(x,y,ffcactivated);
9674 21385 }
9675
9676
2/2
✓ Branch 0 taken 211207 times.
✓ Branch 1 taken 124326 times.
335533 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9677 {
9678
2/2
✓ Branch 0 taken 11074 times.
✓ Branch 1 taken 113252 times.
124326 if(lasthitclk>0)
9679 {
9680 11074 --lasthitclk;
9681 11074 }
9682 else
9683 {
9684 113252 lasthit=-1;
9685 }
9686
9687 124326 bool hitenemy=false;
9688
9689
2/2
✓ Branch 0 taken 864860 times.
✓ Branch 1 taken 124326 times.
989186 for(int32_t j=0; j<guys.Count(); j++)
9690 {
9691
4/4
✓ Branch 0 taken 740534 times.
✓ Branch 1 taken 124326 times.
✓ Branch 2 taken 10183 times.
✓ Branch 3 taken 730351 times.
864860 if((j!=index) && (lasthit!=j))
9692 {
9693
2/2
✓ Branch 0 taken 726682 times.
✓ Branch 1 taken 3669 times.
730351 if(hit(guys.spr(j)))
9694 {
9695 3669 lasthit=j;
9696 3669 lasthitclk=10;
9697 3669 hitenemy=true;
9698 3669 guys.spr(j)->lasthit=index;
9699 3669 guys.spr(j)->lasthitclk=10;
9700 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9701 3669 }
9702 730351 }
9703 864860 }
9704
9705
5/6
✓ Branch 0 taken 121171 times.
✓ Branch 1 taken 3155 times.
✓ Branch 2 taken 121171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2831 times.
✓ Branch 5 taken 118340 times.
124326 if(!trapmove(dir) || clip() || hitenemy)
9706 {
9707
3/4
✓ Branch 0 taken 2831 times.
✓ Branch 1 taken 3155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2831 times.
5986 if(!trapmove(dir) || clip())
9708 {
9709 3155 lasthit=-1;
9710 3155 lasthitclk=0;
9711 3155 }
9712
9713
2/2
✓ Branch 0 taken 5624 times.
✓ Branch 1 taken 362 times.
5986 if(get_qr(qr_MORESOUNDS))
9714 362 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9715
9716 5986 dir=dir^1;
9717 5986 }
9718
9719 124326 sprite::move(step);
9720 124326 }
9721 else
9722 {
9723
3/4
✓ Branch 0 taken 204288 times.
✓ Branch 1 taken 6919 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 204288 times.
211207 if(!trapmove(dir) || clip())
9724 {
9725
2/2
✓ Branch 0 taken 5398 times.
✓ Branch 1 taken 1521 times.
6919 if(get_qr(qr_MORESOUNDS))
9726 1521 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9727
9728 6919 dir=dir^1;
9729 6919 }
9730
9731 211207 sprite::move(step);
9732 }
9733
9734 335533 return enemy::animate(index);
9735 346559 }
9736
9737 341519 bool eTrap2::trapmove(int32_t ndir)
9738 {
9739
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 339641 times.
341519 if(tmpscr->flags2&fFLOATTRAPS)
9740 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9741
9742 339641 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9743 341519 }
9744
9745 328290 bool eTrap2::clip()
9746 {
9747
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 88320 times.
✓ Branch 2 taken 89029 times.
✓ Branch 3 taken 75153 times.
✓ Branch 4 taken 75788 times.
328290 switch(dir)
9748 {
9749 case up:
9750
1/2
✓ Branch 0 taken 88320 times.
✗ Branch 1 not taken.
88320 if(y<=0) return true;
9751
9752 88320 break;
9753
9754 case down:
9755
1/2
✓ Branch 0 taken 89029 times.
✗ Branch 1 not taken.
89029 if(y>=160) return true;
9756
9757 89029 break;
9758
9759 case left:
9760
1/2
✓ Branch 0 taken 75153 times.
✗ Branch 1 not taken.
75153 if(x<=0) return true;
9761
9762 75153 break;
9763
9764 case right:
9765
1/2
✓ Branch 0 taken 75788 times.
✗ Branch 1 not taken.
75788 if(x>=240) return true;
9766
9767 75788 break;
9768 }
9769
9770 328290 return false;
9771 328290 }
9772
9773 350933 void eTrap2::draw(BITMAP *dest)
9774 {
9775 350933 update_enemy_frame();
9776 350933 enemy::draw(dest);
9777 350933 }
9778
9779 3169 int32_t eTrap2::takehit(weapon*,weapon*)
9780 {
9781 3169 return 0;
9782 }
9783
9784 354 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9785 354 {
9786 //do not show "enemy appering" anim -DD
9787 354 clk=0;
9788 354 mainguy=false;
9789 354 clk2=-14;
9790 //Enemy Editor Size Tab
9791
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 init_size_flags();
9792 //nets+1640;
9793 354 }
9794
9795 354 void eRock::init_size_flags()
9796 {
9797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
9798 354 else hxofs = -2;
9799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
9800 354 else hyofs = -2;
9801
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
9802 354 else hit_width = 20;
9803
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
9804 354 else hit_height = 20;
9805
9806
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9807
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
9808
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
9809
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
9810
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
9811 {
9812 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9813 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
9814 }
9815
9816
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
9817 354 }
9818
9819 121997 bool eRock::animate(int32_t index)
9820 {
9821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(switch_hooked) return enemy::animate(index);
9822
2/4
✓ Branch 0 taken 121997 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 121997 times.
121997 if(fallclk||drownclk) return enemy::animate(index);
9823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(dying)
9824 return Dead(index);
9825
9826
2/2
✓ Branch 0 taken 113621 times.
✓ Branch 1 taken 8376 times.
121997 if(clk==0)
9827 {
9828 8376 removearmos(x,y,ffcactivated);
9829 8376 }
9830
9831
2/2
✓ Branch 0 taken 121300 times.
✓ Branch 1 taken 697 times.
121997 if(++clk2==0) // start it
9832 {
9833 697 x=zc_oldrand()&0xF0;
9834 697 y=0;
9835 697 clk3=0;
9836 697 clk2=zc_oldrand()&15;
9837 697 }
9838
9839
2/2
✓ Branch 0 taken 22820 times.
✓ Branch 1 taken 99177 times.
121997 if(clk2>16) // move it
9840 {
9841
2/2
✓ Branch 0 taken 95747 times.
✓ Branch 1 taken 3430 times.
99177 if(clk3<=0) // start bounce
9842 {
9843 3430 dir=zc_oldrand()&1;
9844
9845
2/2
✓ Branch 0 taken 3063 times.
✓ Branch 1 taken 367 times.
3430 if(x<32) dir=1;
9846
9847
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 297 times.
3430 if(x>208) dir=0;
9848 3430 }
9849
9850
2/2
✓ Branch 0 taken 95993 times.
✓ Branch 1 taken 3184 times.
99177 if(clk3<13+16)
9851 {
9852 95993 x += dir ? 1 : -1; //right, left
9853 95993 dummy_int[1]=dir;
9854
9855
2/2
✓ Branch 0 taken 6852 times.
✓ Branch 1 taken 89141 times.
95993 if(clk3<2)
9856 {
9857 6852 y-=2; //up
9858 6852 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9859 6852 }
9860
2/2
✓ Branch 0 taken 10208 times.
✓ Branch 1 taken 78933 times.
89141 else if(clk3<5)
9861 {
9862 10208 y--; //up
9863 10208 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9864 10208 }
9865
2/2
✓ Branch 0 taken 10135 times.
✓ Branch 1 taken 68798 times.
78933 else if(clk3<8)
9866 {
9867 10135 dummy_int[2]=(dummy_int[1]==1)?right:left;
9868 10135 }
9869
2/2
✓ Branch 0 taken 10058 times.
✓ Branch 1 taken 58740 times.
68798 else if(clk3<11)
9870 {
9871 10058 y++; //down
9872 10058 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9873 10058 }
9874 else
9875 {
9876 58740 y+=2; //down
9877 58740 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9878 }
9879
9880 95993 ++clk3;
9881 95993 }
9882
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 423 times.
3184 else if(y<176)
9883 2761 clk3=0; // next bounce
9884 else
9885 423 clk2 = -(zc_oldrand()&63); // back to top
9886 99177 }
9887
9888 121997 return enemy::animate(index);
9889 121997 }
9890
9891 51441 void eRock::drawshadow(BITMAP *dest, bool translucent)
9892 {
9893
2/2
✓ Branch 0 taken 7191 times.
✓ Branch 1 taken 44250 times.
51441 if(clk2>=0)
9894 {
9895 44250 int32_t tempy=yofs;
9896 44250 flip = 0;
9897 44250 int32_t fdiv = frate/4;
9898
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
9899
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t f2=get_qr(qr_NEWENEMYTILES)?
9900 44250 efrate:((clk>=(frate>>1))?1:0);
9901 44250 shadowtile = wpnsbuf[spr_shadow].tile+f2;
9902
9903 44250 yofs+=8;
9904
6/6
✓ Branch 0 taken 20474 times.
✓ Branch 1 taken 23776 times.
✓ Branch 2 taken 38962 times.
✓ Branch 3 taken 5288 times.
✓ Branch 4 taken 19073 times.
✓ Branch 5 taken 19889 times.
44250 yofs+=zc_max(0,zc_min(29-clk3,clk3));
9905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44250 times.
44250 if(!shadow_overpit(this))
9906 44250 sprite::drawshadow(dest, translucent);
9907 44250 yofs=tempy;
9908 44250 }
9909 51441 }
9910
9911 122078 void eRock::draw(BITMAP *dest)
9912 {
9913
4/6
✓ Branch 0 taken 17035 times.
✓ Branch 1 taken 105043 times.
✓ Branch 2 taken 17035 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17035 times.
122078 if(clk2>=0 || fallclk||drownclk)
9914 {
9915 105043 int32_t tempdir=dir;
9916 105043 dir=dummy_int[2];
9917 105043 update_enemy_frame();
9918 105043 enemy::draw(dest);
9919 105043 dir=tempdir;
9920 105043 }
9921 122078 }
9922
9923 1014 int32_t eRock::takehit(weapon*,weapon*)
9924 {
9925 1014 return 0;
9926 }
9927
9928 30 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9929 30 {
9930 30 clk=0;
9931 30 mainguy=false;
9932 30 clk2=-14;
9933
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 init_size_flags();
9934 //nets+1680;
9935 30 }
9936
9937 4440 bool eBoulder::animate(int32_t index)
9938 {
9939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
9940
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
9941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
9942 return Dead(index);
9943
9944
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
9945 {
9946 290 removearmos(x,y,ffcactivated);
9947 290 }
9948
9949 zfix *vert;
9950
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & move_use_fake_z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
9951
9952
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
9953 {
9954 32 x=zc_oldrand()&0xF0;
9955 32 y=-32;
9956 32 clk3=0;
9957 32 clk2=zc_oldrand()&15;
9958 32 }
9959
9960
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
9961 {
9962
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
9963 {
9964 131 dir=zc_oldrand()&1;
9965
9966
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
9967
9968
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
9969 131 }
9970
9971
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
9972 {
9973 3487 x += dir ? 1 : -1; //right, left
9974 3487 dummy_int[1]=dir;
9975
9976
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
9977 {
9978 261 y-=2; //up
9979 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9980 261 }
9981
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
9982 {
9983 382 y--; //up
9984 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9985 382 }
9986
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
9987 {
9988 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
9989 376 }
9990
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
9991 {
9992 367 y++; //down
9993 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9994 367 }
9995 else
9996 {
9997 2101 y+=2; //down
9998 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9999 }
10000
10001 3487 ++clk3;
10002 3487 }
10003
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
10004 101 clk3=0; // next bounce
10005 else
10006 10 clk2 = -(zc_oldrand()&63); // back to top
10007 3598 }
10008
10009 4440 return enemy::animate(index);
10010 4440 }
10011
10012 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
10013 {
10014
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
10015 {
10016 3868 int32_t tempy=yofs;
10017 3868 flip = 0;
10018 3868 int32_t f2=((clk<<2)/frate)<<1;
10019 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10020
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10021
10022 3868 yofs+=8;
10023 3868 xofs-=8;
10024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10025 3868 sprite::drawshadow(dest, translucent);
10026 3868 xofs+=16;
10027 3868 ++shadowtile;
10028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10029 3868 sprite::drawshadow(dest, translucent);
10030 3868 yofs+=16;
10031 3868 shadowtile+=20;
10032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10033 3868 sprite::drawshadow(dest, translucent);
10034 3868 xofs-=16;
10035 3868 --shadowtile;
10036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10037 3868 sprite::drawshadow(dest, translucent);
10038 3868 xofs+=8;
10039 3868 yofs=tempy;
10040 3868 }
10041 4440 }
10042
10043 4440 void eBoulder::draw(BITMAP *dest)
10044 {
10045
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
10046 {
10047 3868 int32_t tempdir=dir;
10048 3868 dir=dummy_int[2];
10049 3868 update_enemy_frame();
10050 3868 dir=tempdir;
10051 3868 xofs-=8;
10052 3868 yofs-=8;
10053 3868 drawblock(dest,15);
10054 3868 xofs+=8;
10055 3868 yofs+=8;
10056 // enemy::draw(dest);
10057 3868 }
10058 4440 }
10059
10060 30 void eBoulder::init_size_flags()
10061 {
10062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
10063 30 else hxofs = -10;
10064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
10065 30 else hyofs = -10;
10066
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10067 30 else hit_width = 36;
10068
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
10069 30 else hit_height = 36;
10070
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
10071 30 else hzsz = 16; //can't be jumped
10072
10073
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10074
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
10075
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10076
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
10077
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
10078 {
10079 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10080 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
10081 }
10082
10083
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
10084 30 }
10085
10086 int32_t eBoulder::takehit(weapon*,weapon*)
10087 {
10088 return 0;
10089 }
10090
10091 4429 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10092
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 3898 times.
4429 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10093 4429 {
10094 /* fixing
10095 hp=1;
10096 */
10097 4429 mainguy=false;
10098
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4422 times.
4429 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10099 4429 hclk=clk; // the "no fire" range
10100 4429 clk=0;
10101 4429 clk3=96;
10102 4429 timer=0;
10103
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 4415 times.
4429 if(o_tile==0)
10104 {
10105 4415 superman=1;
10106 4415 hxofs=1000;
10107 4415 }
10108
1/4
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4429 if (SIZEflags != 0) init_size_flags();;
10109 4429 }
10110
10111 2504746 bool eProjectile::animate(int32_t index)
10112 {
10113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2504746 times.
2504746 if(switch_hooked) return enemy::animate(index);
10114
2/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2504746 times.
2504746 if(fallclk||drownclk) return enemy::animate(index);
10115
2/2
✓ Branch 0 taken 2492420 times.
✓ Branch 1 taken 12326 times.
2504746 if(clk==0)
10116 {
10117 12326 removearmos(x,y,ffcactivated);
10118 12326 }
10119
10120 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10121 2504746 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10122
10123
4/4
✓ Branch 0 taken 835608 times.
✓ Branch 1 taken 1669138 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 403631 times.
2504746 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10124 {
10125 403631 dir=down;
10126 403631 }
10127
4/4
✓ Branch 0 taken 1348897 times.
✓ Branch 1 taken 752218 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 916920 times.
2101115 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10128 {
10129 916920 dir=right;
10130 916920 }
10131
4/4
✓ Branch 0 taken 790877 times.
✓ Branch 1 taken 393318 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 358900 times.
1184195 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10132 {
10133 358900 dir=up;
10134 358900 }
10135 else
10136 {
10137 825295 dir=left;
10138 }
10139
10140
3/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1306267 times.
✓ Branch 3 taken 1198479 times.
2504746 if(!stunclk && ++clk3>80)
10141 {
10142
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 1197433 times.
1198479 if(dmisc1==9) // Breath type
10143 {
10144
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 563 times.
1046 if(timer==0)
10145 {
10146 563 unsigned r=zc_oldrand();
10147
10148
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 557 times.
563 if(!(r&63))
10149 {
10150 6 timer=zc_oldrand()%50+50;
10151 6 }
10152 563 }
10153
10154
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 489 times.
1046 if(timer>0)
10155 {
10156
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 119 times.
489 if(timer%4==0)
10157 {
10158 119 FireBreath(false);
10159 119 }
10160
10161
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 6 times.
489 if(--timer==0)
10162 {
10163 6 clk3=0;
10164 6 }
10165 489 }
10166 1046 }
10167
10168 else // Not breath type
10169 {
10170 1197433 unsigned r=zc_oldrand();
10171
10172
4/4
✓ Branch 0 taken 18808 times.
✓ Branch 1 taken 1178625 times.
✓ Branch 2 taken 1266 times.
✓ Branch 3 taken 17542 times.
1197433 if(!(r&63) && !HeroInRange(minRange))
10173 {
10174 17542 FireWeapon();
10175
10176
4/4
✓ Branch 0 taken 15040 times.
✓ Branch 1 taken 2502 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 66 times.
17794 if(get_qr(qr_BROKENSTATUES)==0 &&
10177
3/4
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14788 times.
✓ Branch 2 taken 252 times.
✗ Branch 3 not taken.
15040 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10178 {
10179
2/2
✓ Branch 0 taken 13945 times.
✓ Branch 1 taken 909 times.
14854 if(!((r>>7)&15))
10180 {
10181 909 x-=4;
10182 909 FireWeapon();
10183 909 x+=4;
10184 909 }
10185 14854 }
10186
10187 17542 clk3=0;
10188 17542 }
10189 }
10190 1198479 }
10191
10192 2504746 return enemy::animate(index);
10193 2504746 }
10194
10195 2520335 void eProjectile::draw(BITMAP *dest)
10196 {
10197 2520335 update_enemy_frame();
10198 2520335 enemy::draw(dest);
10199 2520335 }
10200
10201 533 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10202 533 {
10203 533 hxofs=1000;
10204 533 }
10205
10206 249811 void eTrigger::draw(BITMAP *dest)
10207 {
10208 249811 update_enemy_frame();
10209 249811 enemy::draw(dest);
10210 249811 }
10211
10212 void eTrigger::death_sfx()
10213 {
10214 //silent death
10215 }
10216
10217 5 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10218 5 {
10219 5 o_tile+=wpnsbuf[iwNPCs].tile;
10220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10221 5 SIZEflags = d->SIZEflags;
10222
1/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if (SIZEflags != 0) init_size_flags();;
10223 5 }
10224
10225 75 bool eNPC::animate(int32_t index)
10226 {
10227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(switch_hooked) return enemy::animate(index);
10228
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 5 times.
75 if(dying)
10229 70 return Dead(index);
10230
10231
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(clk==0)
10232 {
10233 removearmos(x,y,ffcactivated);
10234 }
10235
10236
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 switch(dmisc2)
10237 {
10238 case 0:
10239 {
10240 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10241 5 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10242
10243
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10244 {
10245 dir=down;
10246 }
10247
10248
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10249 {
10250 5 dir=right;
10251 5 }
10252 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10253 {
10254 dir=up;
10255 }
10256 else
10257 {
10258 dir=left;
10259 }
10260 }
10261 5 break;
10262
10263 case 1:
10264 halting_walk(rate, homing, 0, hrate, 48);
10265
10266 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10267 {
10268 newdir(rate, homing, 0);
10269 clk2=48;
10270 ++misc;
10271 }
10272
10273 if(clk2==0)
10274 misc=0;
10275
10276 break;
10277 }
10278
10279 5 return enemy::animate(index);
10280 75 }
10281
10282 75 void eNPC::draw(BITMAP *dest)
10283 {
10284 75 update_enemy_frame();
10285 75 enemy::draw(dest);
10286 75 }
10287
10288 int32_t eNPC::takehit(weapon*,weapon*)
10289 {
10290 return 0;
10291 }
10292
10293 94 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10294 94 {
10295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10296 {
10297 94 o_tile=clk;
10298 94 cs=id>>12;
10299 94 }
10300
10301 94 id=id&0xFFF;
10302 94 clk=0;
10303
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10304 94 mainguy=false;
10305 94 SIZEflags = d->SIZEflags;
10306
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if (SIZEflags != 0) init_size_flags();;
10307 94 }
10308
10309 81 void eSpinTile::facehero()
10310 {
10311
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10312 {
10313
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10314 1 dir = up;
10315 else
10316 dir = down;
10317 1 }
10318 else
10319 {
10320 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10321 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10322
10323
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10324 {
10325 12 dir=l_down;
10326 12 }
10327
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10328 {
10329 1 dir=down;
10330 1 }
10331
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10332 {
10333 12 dir=r_down;
10334 12 }
10335
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10336 {
10337 6 dir=right;
10338 6 }
10339
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10340 {
10341 17 dir=r_up;
10342 17 }
10343
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10344 {
10345 8 dir=up;
10346 8 }
10347
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10348 {
10349 6 dir=l_up;
10350 6 }
10351 else
10352 {
10353 18 dir=left;
10354 }
10355 }
10356 81 }
10357
10358
10359 15539 bool eSpinTile::animate(int32_t index)
10360 {
10361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10362
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10363
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10364 {
10365 1152 return Dead(index);
10366 }
10367
10368
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10369 {
10370 1241 removearmos(x,y,ffcactivated);
10371 1241 }
10372
10373 14387 ++misc;
10374
10375
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10376 {
10377 81 facehero();
10378 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10379 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10380 81 angular=true;
10381 81 angle=ddir;
10382 81 step=zslongToFix(dstep*100);
10383 81 }
10384
10385
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10386 52 kickbucket();
10387
10388 14387 sprite::move(step);
10389 14387 return enemy::animate(index);
10390 15539 }
10391
10392 15457 void eSpinTile::draw(BITMAP *dest)
10393 {
10394 15457 update_enemy_frame();
10395 15457 y-=(misc>>4);
10396 15457 yofs+=2;
10397 15457 enemy::draw(dest);
10398 15457 yofs-=2;
10399 15457 y+=(misc>>4);
10400 15457 }
10401
10402 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10403 {
10404 15457 flip = 0;
10405 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10406 15457 yofs+=4;
10407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
10408 15457 enemy::drawshadow(dest, translucent);
10409 15457 yofs-=4;
10410 15457 }
10411
10412 2765 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10413 2765 {
10414 //these are here to bypass compiler warnings about unused arguments
10415 2765 Clk=Clk;
10416 2765 mainguy=false;
10417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2765 times.
2765 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10418 /*if((x>-17 && x<0) && iswaterex(tmpscr->data[(((int32_t)y&0xF0)+((int32_t)x>>4))]))
10419 {
10420 clk=1;
10421 }*/
10422 //nets+880;
10423
1/4
✓ Branch 0 taken 2765 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2765 if (SIZEflags != 0) init_size_flags();;
10424 2765 }
10425
10426 623626 void eZora::facehero()
10427 {
10428
2/2
✓ Branch 0 taken 10785 times.
✓ Branch 1 taken 612841 times.
623626 if(Hero.x-x==0)
10429 {
10430 10785 dir=(Hero.y+8<y)?up:down;
10431 10785 }
10432 else
10433 {
10434 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10435 612841 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10436
10437
4/4
✓ Branch 0 taken 124342 times.
✓ Branch 1 taken 488499 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 78312 times.
612841 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10438 {
10439 78312 dir=l_down;
10440 78312 }
10441
4/4
✓ Branch 0 taken 90275 times.
✓ Branch 1 taken 444254 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 44245 times.
534529 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10442 {
10443 44245 dir=down;
10444 44245 }
10445
4/4
✓ Branch 0 taken 119526 times.
✓ Branch 1 taken 370758 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 73496 times.
490284 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10446 {
10447 73496 dir=r_down;
10448 73496 }
10449
4/4
✓ Branch 0 taken 160722 times.
✓ Branch 1 taken 256066 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 114692 times.
416788 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10450 {
10451 114692 dir=right;
10452 114692 }
10453
4/4
✓ Branch 0 taken 125815 times.
✓ Branch 1 taken 176281 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 79785 times.
302096 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10454 {
10455 79785 dir=r_up;
10456 79785 }
10457
4/4
✓ Branch 0 taken 87885 times.
✓ Branch 1 taken 134426 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 41855 times.
222311 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10458 {
10459 41855 dir=up;
10460 41855 }
10461
4/4
✓ Branch 0 taken 120580 times.
✓ Branch 1 taken 59876 times.
✓ Branch 2 taken 74550 times.
✓ Branch 3 taken 46030 times.
180456 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10462 {
10463 74550 dir=l_up;
10464 74550 }
10465 else
10466 {
10467 105906 dir=left;
10468 }
10469 }
10470 623626 }
10471
10472 852265 bool eZora::animate(int32_t index)
10473 {
10474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 852265 times.
852265 if(switch_hooked) return enemy::animate(index);
10475
2/2
✓ Branch 0 taken 2754 times.
✓ Branch 1 taken 849511 times.
852265 if(dying)
10476 2754 return Dead(index);
10477
10478
2/2
✓ Branch 0 taken 843799 times.
✓ Branch 1 taken 5712 times.
849511 if(clk==0)
10479 {
10480 5712 removearmos(x,y,ffcactivated);
10481 5712 }
10482
10483
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 849476 times.
849511 if(watch)
10484 {
10485 35 ++clock_zoras[id];
10486 35 return true;
10487 }
10488
10489
2/2
✓ Branch 0 taken 225850 times.
✓ Branch 1 taken 623626 times.
849476 if(get_qr(qr_NEWENEMYTILES))
10490 {
10491 623626 facehero();
10492 623626 }
10493
10494
6/6
✓ Branch 0 taken 5200 times.
✓ Branch 1 taken 4963 times.
✓ Branch 2 taken 4164 times.
✓ Branch 3 taken 825736 times.
✓ Branch 4 taken 6448 times.
✓ Branch 5 taken 2965 times.
849476 switch(clk)
10495 {
10496 case 0: // reposition him
10497 {
10498 6448 int32_t t=0;
10499 6448 int32_t pos2=zc_oldrand()%160 + 16;
10500 6448 bool placed=false;
10501
10502
4/4
✓ Branch 0 taken 6383 times.
✓ Branch 1 taken 38203 times.
✓ Branch 2 taken 26108 times.
✓ Branch 3 taken 5712 times.
44586 while(!placed && t<160)
10503 {
10504 26108 int32_t watertype = iswaterex(tmpscr->data[pos2], currmap, currscr, -1, ((pos2)%16*16), ((pos2)&0xF0), false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10505
5/6
✓ Branch 0 taken 6570 times.
✓ Branch 1 taken 19538 times.
✓ Branch 2 taken 6570 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 400 times.
✓ Branch 5 taken 5647 times.
32155 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10506
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 6538 times.
6570 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10507
3/4
✓ Branch 0 taken 6538 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6047 times.
✓ Branch 3 taken 6015 times.
6570 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10508 {
10509 5647 x=(pos2&15)<<4;
10510 5647 y=pos2&0xF0;
10511
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 5307 times.
5647 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10512 5647 hxofs=1000; // avoid hit detection
10513 5647 stunclk=0;
10514 5647 placed=true;
10515 5647 }
10516
10517 38138 pos2+=19;
10518
10519
2/2
✓ Branch 0 taken 33615 times.
✓ Branch 1 taken 4523 times.
38138 if(pos2>=176)
10520 4523 pos2-=160;
10521
10522 38138 ++t;
10523 }
10524
10525
3/4
✓ Branch 0 taken 5647 times.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5647 times.
5712 if(!placed || whistleclk>=88) // can't place him, he's gone
10526 65 return true;
10527
10528 }
10529 5647 break;
10530
10531 case 35:
10532
2/2
✓ Branch 0 taken 3839 times.
✓ Branch 1 taken 1361 times.
5200 if(!get_qr(qr_NEWENEMYTILES))
10533 {
10534 1361 dir=(Hero.y+8<y)?up:down;
10535 1361 }
10536
10537 5200 hxofs=0;
10538 5200 break;
10539
10540 case 35+19:
10541 4963 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10542 4963 sfx(wpnsfx(wpn),pan(int32_t(x)));
10543 4963 break;
10544
10545 case 35+66:
10546 4164 hxofs=1000;
10547 4164 break;
10548
10549 case 198:
10550 2965 clk=-1;
10551 2965 break;
10552 }
10553
10554 848675 return enemy::animate(index);
10555 851529 }
10556
10557 857650 void eZora::draw(BITMAP *dest)
10558 {
10559
2/2
✓ Branch 0 taken 16963 times.
✓ Branch 1 taken 840687 times.
857650 if(clk<3)
10560 16963 return;
10561
10562 840687 update_enemy_frame();
10563 840687 enemy::draw(dest);
10564 857650 }
10565
10566 232 bool eZora::isSubmerged() const
10567 {
10568 232 return ( clk < 3 );
10569 }
10570
10571
3/6
✓ Branch 0 taken 50114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50114 times.
✗ Branch 5 not taken.
100228 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10572 50114 {
10573 50114 multishot= timer = fired = dashing = 0;
10574 50114 hashero = false;
10575 50114 dummy_bool[0]=false;
10576
4/8
✓ Branch 0 taken 50114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50114 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50114 times.
✗ Branch 7 not taken.
50114 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
10577
5/6
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 49154 times.
✓ Branch 2 taken 960 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 495 times.
✓ Branch 5 taken 465 times.
50114 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10578 {
10579
2/4
✓ Branch 0 taken 495 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 495 times.
✗ Branch 3 not taken.
495 step=zslongToFix(dmisc10*100);
10580
10581
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 477 times.
495 if(anim==aARMOS4) o_tile+=20;
10582 495 }
10583
10584
3/4
✓ Branch 0 taken 50114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 960 times.
✓ Branch 3 taken 49154 times.
50114 if(flags & guy_fade_flicker)
10585 {
10586 960 clk=0;
10587 960 superman = 1;
10588 960 fading=fade_flicker;
10589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
960 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10590 960 dir=down;
10591
10592
4/6
✓ Branch 0 taken 960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 960 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✓ Branch 5 taken 551 times.
960 if(!canmove(down,(zfix)8,spw_none,false))
10593
3/6
✓ Branch 0 taken 409 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 409 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✗ Branch 5 not taken.
409 clk3=int32_t(13.0/step);
10594 960 }
10595
3/4
✓ Branch 0 taken 49154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49021 times.
✓ Branch 3 taken 133 times.
49154 else if(flags & guy_fade_instant)
10596 {
10597 133 clk=0;
10598 133 }
10599
10600
1/2
✓ Branch 0 taken 50114 times.
✗ Branch 1 not taken.
50114 shadowdistance = 0;
10601 50114 clk4 = clk5 = 0;
10602 //nets+2380;
10603
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50112 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
50114 if (SIZEflags != 0) init_size_flags();;
10604 50114 }
10605
10606 15797387 bool eStalfos::animate(int32_t index)
10607 {
10608
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 15797131 times.
15797387 if(switch_hooked) return enemy::animate(index);
10609
3/4
✓ Branch 0 taken 15796705 times.
✓ Branch 1 taken 426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15796705 times.
15797131 if(fallclk||drownclk)
10610 {
10611 426 return enemy::animate(index);
10612 }
10613
2/2
✓ Branch 0 taken 352672 times.
✓ Branch 1 taken 15444033 times.
15796705 if(dying)
10614 {
10615
2/2
✓ Branch 0 taken 352624 times.
✓ Branch 1 taken 48 times.
352672 if(hashero)
10616 {
10617 48 Hero.setEaten(0);
10618 48 hashero=false;
10619 48 }
10620
10621
10/14
✓ Branch 0 taken 35920 times.
✓ Branch 1 taken 316752 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 32235 times.
✓ Branch 4 taken 187 times.
✓ Branch 5 taken 3498 times.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 187 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 187 times.
352672 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10622 {
10623 187 hp=-1000;
10624
5/10
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
187 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10625 187 Ewpns.add(ew);
10626 187 ew->fakez = fakez;
10627
10628
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
187 if(wpn==ewSBomb || wpn==ewBomb)
10629 {
10630 187 ew->step=0;
10631 187 ew->id=wpn;
10632 187 ew->misc=50;
10633 187 ew->clk=48;
10634 187 }
10635
10636 187 fired=true;
10637 187 }
10638
6/6
✓ Branch 0 taken 156252 times.
✓ Branch 1 taken 196233 times.
✓ Branch 2 taken 130200 times.
✓ Branch 3 taken 26052 times.
✓ Branch 4 taken 130182 times.
✓ Branch 5 taken 18 times.
352485 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10639 {
10640
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10641 {
10642 1 int32_t wpn2 = wpn+dmisc3;
10643
10644
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10645 {
10646 wpn2=wpn;
10647 }
10648
10649 1 dummy_bool[0]=true;
10650 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10651 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10652 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10653 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10654 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10655 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10656 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10657 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10658 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10659 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10660 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10661 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10662 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10663 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10664 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10665 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10666 1 sfx(wpnsfx(wpn2),pan(int32_t(x)));
10667 1 }
10668 18 }
10669
10670 352672 KillWeapon();
10671 352672 return Dead(index);
10672 }
10673 //vire split
10674 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10675 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10676
13/14
✓ Branch 0 taken 21124 times.
✓ Branch 1 taken 15422909 times.
✓ Branch 2 taken 21124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✓ Branch 5 taken 20773 times.
✓ Branch 6 taken 1192696 times.
✓ Branch 7 taken 14250986 times.
✓ Branch 8 taken 1191149 times.
✓ Branch 9 taken 1547 times.
✓ Branch 10 taken 6686 times.
✓ Branch 11 taken 1184463 times.
✓ Branch 12 taken 1326 times.
✓ Branch 13 taken 5360 times.
15444033 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10677 {
10678 1677 stop_bgsfx(index);
10679 1677 int32_t kids = guys.Count();
10680 1677 int32_t id2=dmisc3;
10681
2/2
✓ Branch 0 taken 3307 times.
✓ Branch 1 taken 1677 times.
4984 for(int32_t i=0; i < dmisc4; i++)
10682 {
10683 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
10684
4/6
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 2035 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2035 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3307 times.
3307 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10685 3307 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10686 3307 }
10687
10688
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 1 times.
1677 if(itemguy) // Hand down the carried item
10689 {
10690 1 guycarryingitem = guys.Count()-1;
10691 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10692 1 itemguy = false;
10693 1 }
10694
10695
2/2
✓ Branch 0 taken 1660 times.
✓ Branch 1 taken 17 times.
1677 if(hashero)
10696 {
10697 17 Hero.setEaten(0);
10698 17 hashero=false;
10699 17 }
10700
10701
4/4
✓ Branch 0 taken 1649 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 1326 times.
✓ Branch 3 taken 323 times.
1677 if(deadsfx > 0 && dmisc2==e2tSPLIT)
10702 323 sfx(deadsfx,pan(int32_t(x)));
10703
10704 1677 return true;
10705 }
10706 /*
10707 else if((dmisc2==e2tSPLITHIT && (hp<=0 && !immortal) &&!slide())) //Possible vires fix; or could cause goodness knows what. -Z
10708 {
10709 stop_bgsfx(index);
10710 int32_t kids = guys.Count();
10711 int32_t id2=dmisc3;
10712
10713 for(int32_t i=0; i < dmisc4; i++)
10714 {
10715 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
10716 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : (i<<12)),-21-(i%4)))
10717 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10718 }
10719
10720 if(itemguy) // Hand down the carried item
10721 {
10722 guycarryingitem = guys.Count()-1;
10723 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10724 itemguy = false;
10725 }
10726
10727 if(hashero)
10728 {
10729 Hero.setEaten(0);
10730 hashero=false;
10731 }
10732
10733 return true;
10734 }
10735 */
10736
2/2
✓ Branch 0 taken 68836 times.
✓ Branch 1 taken 15373520 times.
15442356 if(fading)
10737 {
10738
2/2
✓ Branch 0 taken 1190 times.
✓ Branch 1 taken 67646 times.
68836 if(++clk4 > 60)
10739 {
10740 1190 clk4=0;
10741 1190 superman=0;
10742 1190 fading=0;
10743
10744
4/6
✓ Branch 0 taken 929 times.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 929 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 929 times.
1190 if(flags&guy_armos && z==0 && fakez == 0)
10745 {
10746 //if a custom size (not 16px by 16px)
10747
10748 //if a custom size (not 16px by 16px)
10749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 929 times.
929 if (ffcactivated)
10750 removearmosffc(ffcactivated-1);
10751 else
10752 {
10753
4/8
✓ Branch 0 taken 929 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 929 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 929 times.
929 if (txsz > 1 || tysz > 1 || (SIZEflags&OVERRIDE_HIT_WIDTH) || (SIZEflags&OVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10754 {
10755 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10756 for(int32_t dx = 0; dx < tysz; dx ++)
10757 {
10758 for(int32_t dy = 0; dy < tysz; dy++)
10759 {
10760 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
10761 did_armos = false;
10762 }
10763 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
10764 did_armos = false;
10765 }
10766 for(int32_t dy = 0; dy < tysz; dy ++)
10767 {
10768 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
10769 did_armos = false;
10770 }
10771 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
10772 }
10773 929 else removearmos(x,y);
10774 }
10775 /*
10776 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10777 {
10778 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10779 for(int32_t dx = 0; dx < hxsz; dx += 16)
10780 {
10781 for(int32_t dy = 0; dy < hysz; dy += 16)
10782 {
10783 removearmos((int32_t)x+dx+hxofs,(int32_t)y+dy+hyofs+1,ffcactivated);
10784 did_armos = false;
10785 }
10786 removearmos((int32_t)x+dx+hxofs, (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
10787 did_armos = false;
10788 }
10789 for(int32_t dy = 0; dy < hysz; dy += 16)
10790 {
10791 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+dy+hyofs-1,ffcactivated);
10792 did_armos = false;
10793 }
10794 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
10795 }
10796 else removearmos(x,y,ffcactivated);
10797 */
10798
10799 929 }
10800
10801 1190 clk2=0;
10802
10803 1190 newdir();
10804 1190 }
10805 67646 else return enemy::animate(index);
10806 1190 }
10807
6/8
✓ Branch 0 taken 143173 times.
✓ Branch 1 taken 15230347 times.
✓ Branch 2 taken 143173 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 143173 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 133968 times.
✓ Branch 7 taken 9205 times.
15373520 else if(flags&guy_armos && z==0 && fakez == 0 && clk==0)
10808 9205 removearmos(x,y,ffcactivated);
10809
10810
10811
2/2
✓ Branch 0 taken 7207 times.
✓ Branch 1 taken 15367503 times.
15374710 if(hashero)
10812 {
10813 7207 Hero.setX(x);
10814 7207 Hero.setY(y);
10815 7207 ++clk2;
10816
10817
4/4
✓ Branch 0 taken 5694 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 6308 times.
✓ Branch 3 taken 899 times.
7207 if(clk2==(dmisc8==0 ? 95 : dmisc8))
10818 {
10819
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 877 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
899 switch(dmisc7)
10820 {
10821 case e7tEATITEMS:
10822 {
10823
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<MAXITEMS; i++)
10824 {
10825
2/2
✓ Branch 0 taken 5610 times.
✓ Branch 1 taken 22 times.
5632 if(itemsbuf[i].flags&item_edible)
10826 22 game->set_item(i, false);
10827 5632 }
10828
10829 22 break;
10830 }
10831
10832 case e7tEATMAGIC:
10833 game->change_dmagic(-1*game->get_magicdrainrate());
10834 break;
10835
10836 case e7tEATRUPEES:
10837 game->change_drupy(-1);
10838 break;
10839 }
10840
10841 899 clk2=0;
10842 899 }
10843
10844
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 6661 times.
7207 if((clk&0x18)==8) // stop its animation on the middle frame
10845 6661 --clk;
10846 7207 }
10847
4/4
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14318630 times.
✓ Branch 2 taken 616037 times.
✓ Branch 3 taken 432836 times.
15367503 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
10848 {
10849 // Movement engine
10850
6/6
✓ Branch 0 taken 838865 times.
✓ Branch 1 taken 14095802 times.
✓ Branch 2 taken 3294 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 14092341 times.
✓ Branch 5 taken 59 times.
14934667 if(clk>=0) switch(id>>12)
10851 {
10852 case 0: // Normal movement
10853
10854 /*
10855 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
10856 {
10857 // Overloading clk4 (Tribble clock) here...
10858 step=17/100.0;
10859 if(clk4<32) misc=1;
10860 else if(clk4<48) misc=2;
10861 else if(clk4<300) { misc=3; step = dstep/100.0; }
10862 else if(clk4<316) misc=2;
10863 else if(clk4<412) misc=1;
10864 else if(clk4<540) { misc=0; step=0; }
10865 else clk4=0;
10866 if(clk4==48) clk=0;
10867 hxofs=(misc>=2)?0:1000;
10868 if (dmisc9==e9tLEEVER)
10869 variable_walk(rate, homing, 0);
10870 else
10871 variable_walk_8(rate, homing, 4, 0);
10872 break;
10873 }
10874 */
10875
4/4
✓ Branch 0 taken 13713307 times.
✓ Branch 1 taken 379034 times.
✓ Branch 2 taken 417076 times.
✓ Branch 3 taken 13296231 times.
14092341 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
10876 {
10877 796110 vire_hop();
10878 796110 break;
10879 }
10880
2/2
✓ Branch 0 taken 981551 times.
✓ Branch 1 taken 12314680 times.
13296231 else if(dmisc9==e9tROPE) //Rope charge
10881 {
10882
9/10
✓ Branch 0 taken 964129 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 138340 times.
✓ Branch 3 taken 825789 times.
✓ Branch 4 taken 126255 times.
✓ Branch 5 taken 12085 times.
✓ Branch 6 taken 125430 times.
✓ Branch 7 taken 825 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 125430 times.
981551 if(!fired && dashing && !stunclk && !watch && !frozenclock)
10883 {
10884
5/6
✓ Branch 0 taken 9076 times.
✓ Branch 1 taken 116354 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 9029 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
125430 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
10885 {
10886
10887
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 33 times.
47 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
10888 {
10889 14 hp=-1000;
10890
10891
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10892 {
10893
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
10894 14 Ewpns.add(ew);
10895 14 ew->fakez = fakez;
10896
10897
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
10898 {
10899 14 ew->step=0;
10900 14 ew->id=wpn+dmisc3;
10901 14 ew->misc=50;
10902 14 ew->clk=48;
10903 14 }
10904
10905 14 fired=true;
10906 14 }
10907 else
10908 {
10909 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
10910 Ewpns.add(ew);
10911 ew->fakez = fakez;
10912
10913 if(wpn==ewSBomb || wpn==ewBomb)
10914 {
10915 ew->step=0;
10916 ew->id=wpn;
10917 ew->misc=50;
10918 ew->clk=48;
10919 }
10920
10921 fired=true;
10922 }
10923 14 }
10924
10925 else
10926 {
10927 33 hp=-1000;
10928
10929 int32_t wpn2;
10930
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10931 33 wpn2=wpn;
10932 else
10933 wpn2=wpn;
10934
10935
5/10
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
33 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
10936 33 Ewpns.add(ew);
10937 33 ew->fakez = fakez;
10938
10939
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
33 if(wpn2==ewSBomb || wpn2==ewBomb)
10940 {
10941 33 ew->step=0;
10942 33 ew->id=wpn2;
10943 33 ew->misc=50;
10944 33 ew->clk=48;
10945 33 }
10946
10947 33 fired=true;
10948 }
10949 47 }
10950 125430 }
10951
10952 981551 charge_attack();
10953 981551 break;
10954 }
10955 /*
10956 * Boomerang-throwers have a halt count of 1
10957 * Zols have a halt count of (zc_oldrand()&7)<<4
10958 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
10959 * Everything else has 48
10960 */
10961 else
10962 {
10963
2/2
✓ Branch 0 taken 568419 times.
✓ Branch 1 taken 11746261 times.
12314680 if(wpn==ewBrang) // Goriya
10964 {
10965 568419 halting_walk(rate,homing,0,hrate, 1);
10966 568419 }
10967
4/4
✓ Branch 0 taken 11602159 times.
✓ Branch 1 taken 144102 times.
✓ Branch 2 taken 4547551 times.
✓ Branch 3 taken 7054608 times.
11746261 else if(dmisc9==e9tNORMAL && wpn==0)
10968 {
10969
2/2
✓ Branch 0 taken 717973 times.
✓ Branch 1 taken 6336635 times.
7054608 if(dmisc2==e2tSPLITHIT) // Zol
10970 {
10971 717973 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
10972 717973 }
10973
4/4
✓ Branch 0 taken 1753011 times.
✓ Branch 1 taken 4583624 times.
✓ Branch 2 taken 1537120 times.
✓ Branch 3 taken 215891 times.
6336635 else if(frate<=8 && starting_hp==1) // Gel
10974 {
10975 215891 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
10976 215891 }
10977 else // Other
10978 {
10979 6120744 halting_walk(rate,homing,0,hrate, 48);
10980 }
10981 7054608 }
10982 else // Other
10983 {
10984 4691653 halting_walk(rate,homing,0,hrate, 48);
10985 }
10986 }
10987
10988 //if not in midair, and Hero's swinging sword is nearby, jump.
10989 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
10990 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
10991 {
10992 facehero(false);
10993 sclk=16+((dir^1)<<8);
10994 fall=-FEATHERJUMP;
10995 sfx(WAV_ZN1JUMP,pan(int32_t(x)));
10996 }*/
10997 12314680 break;
10998
10999 // Following cases are for just after creation-by-splitting.
11000 case 1:
11001
2/2
✓ Branch 0 taken 2473 times.
✓ Branch 1 taken 821 times.
3294 if(misc==1)
11002 {
11003 821 dir=up;
11004 821 step=8;
11005 821 }
11006
11007
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 2504 times.
3294 if(misc<=2)
11008 {
11009 2504 move(step);
11010
11011
2/2
✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 512 times.
2504 if(!canmove(dir,(zfix)0,0,false))
11012 512 dir=down;
11013 2504 }
11014
11015
2/2
✓ Branch 0 taken 2504 times.
✓ Branch 1 taken 790 times.
3294 if(misc==3)
11016 {
11017
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 503 times.
790 if(canmove(right,(zfix)16,0,false))
11018 503 x+=16;
11019 790 }
11020
11021 3294 ++misc;
11022 3294 break;
11023
11024 case 2:
11025
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 15 times.
59 if(misc==1)
11026 {
11027 15 dir=down;
11028 15 step=8;
11029 15 }
11030
11031
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45 times.
59 if(misc<=2)
11032 {
11033 45 move(step);
11034 /*
11035 if(!canmove(dir,(zfix)0,0,false))
11036 dir=up;
11037 */
11038 45 }
11039
11040
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 if(misc==3)
11041 {
11042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(canmove(left,(zfix)16,0,false))
11043 14 x-=16;
11044 14 }
11045
11046 59 ++misc;
11047 59 break;
11048
11049 default:
11050
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 28 times.
108 if(misc==1)
11051 {
11052 28 dir=(zc_oldrand()%4);
11053 28 step=8;
11054 28 }
11055
11056
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 83 times.
108 if(misc<=2)
11057 {
11058 83 move(step);
11059
11060
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 2 times.
83 if(!canmove(dir,(zfix)0,0,false))
11061 2 dir=dir^1;
11062 83 }
11063
11064
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 25 times.
108 if(misc==3)
11065 {
11066
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
25 if(dir >= left && canmove(dir,(zfix)16,0,false))
11067 8 x+=(dir==left ? -16 : 16);
11068 25 }
11069
11070 108 ++misc;
11071 108 break;
11072 14095802 }
11073
11074
4/4
✓ Branch 0 taken 25272 times.
✓ Branch 1 taken 14909395 times.
✓ Branch 2 taken 24443 times.
✓ Branch 3 taken 829 times.
14934667 if(id>>12 && misc>=4) //recently spawned by a split enemy
11075 {
11076 829 id&=0xFFF;
11077 829 step = zslongToFix(dstep*100);
11078
11079
1/2
✓ Branch 0 taken 829 times.
✗ Branch 1 not taken.
829 if(x<32) x=32;
11080
11081
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 21 times.
829 if(x>208) x=208;
11082
11083
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 24 times.
829 if(y<32) y=32;
11084
11085
2/2
✓ Branch 0 taken 822 times.
✓ Branch 1 taken 7 times.
829 if(y>128) y=128;
11086
11087 829 misc=3;
11088 829 }
11089 14934667 }
11090 else
11091 {
11092 //sfx(wpnsfx(wpn),pan(int32_t(x)));
11093
1/2
✓ Branch 0 taken 432836 times.
✗ Branch 1 not taken.
432836 if(clk2>2) clk2--;
11094 }
11095
11096 // Fire Zol
11097
8/8
✓ Branch 0 taken 6100121 times.
✓ Branch 1 taken 9274589 times.
✓ Branch 2 taken 139281 times.
✓ Branch 3 taken 5960840 times.
✓ Branch 4 taken 1131 times.
✓ Branch 5 taken 138150 times.
✓ Branch 6 taken 1102 times.
✓ Branch 7 taken 29 times.
15374710 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11098 {
11099 1102 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11100 1102 sfx(wpnsfx(wpn),pan(int32_t(x)));
11101
11102 1102 int32_t i=Ewpns.Count()-1;
11103 1102 weapon *ew = (weapon*)(Ewpns.spr(i));
11104
11105
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1102 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11106 {
11107 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11108 if ( ew->do_animation ) ew->tile+=ew->aframe;
11109 }
11110 1102 }
11111 // Goriya
11112
14/16
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14324735 times.
✓ Branch 2 taken 468534 times.
✓ Branch 3 taken 580339 times.
✓ Branch 4 taken 456235 times.
✓ Branch 5 taken 12299 times.
✓ Branch 6 taken 423258 times.
✓ Branch 7 taken 32977 times.
✓ Branch 8 taken 423258 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 420517 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 420517 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 414155 times.
✓ Branch 15 taken 6362 times.
15373608 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11113 {
11114 6362 misc=index+100;
11115
7/14
✓ Branch 0 taken 6362 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6362 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6362 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6362 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6362 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6362 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6362 times.
✗ Branch 13 not taken.
6362 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11116 6362 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11117
11118
2/2
✓ Branch 0 taken 6105 times.
✓ Branch 1 taken 257 times.
6362 if(dmisc1==2)
11119 {
11120 257 int32_t ndir=dir;
11121
11122
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 251 times.
257 if(Hero.x-x==0)
11123 {
11124 6 ndir=(Hero.y+8<y)?up:down;
11125 6 }
11126 else //turn to face Hero
11127 {
11128 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11129 251 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11130
11131
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 193 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 13 times.
251 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11132 {
11133 13 ndir=down;
11134 13 }
11135
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 68 times.
238 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11136 {
11137 68 ndir=right;
11138 68 }
11139
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 48 times.
170 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11140 {
11141 48 ndir=up;
11142 48 }
11143 else
11144 {
11145 122 ndir=left;
11146 }
11147 }
11148
11149 257 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11150
11151
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 223 times.
257 if(canmove(ndir,false))
11152 {
11153 223 dir=ndir;
11154 223 }
11155 257 }
11156 6362 }
11157
15/16
✓ Branch 0 taken 15308366 times.
✓ Branch 1 taken 58880 times.
✓ Branch 2 taken 221192 times.
✓ Branch 3 taken 15146054 times.
✓ Branch 4 taken 195074 times.
✓ Branch 5 taken 26118 times.
✓ Branch 6 taken 170182 times.
✓ Branch 7 taken 24892 times.
✓ Branch 8 taken 168798 times.
✓ Branch 9 taken 1384 times.
✓ Branch 10 taken 153698 times.
✓ Branch 11 taken 15100 times.
✓ Branch 12 taken 153698 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 152754 times.
15367246 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11158
3/3
✓ Branch 0 taken 26116 times.
✓ Branch 1 taken 125732 times.
✓ Branch 2 taken 906 times.
152754 switch(dmisc1)
11159 {
11160 case e1tCONSTANT: //Deathnut
11161 {
11162 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11163
2/2
✓ Branch 0 taken 123149 times.
✓ Branch 1 taken 2583 times.
125732 if(clk5>64)
11164 {
11165 2583 clk5=0;
11166 2583 fired=false;
11167 2583 }
11168
11169 125732 clk5+=(zc_oldrand()&3);
11170
11171
4/4
✓ Branch 0 taken 76714 times.
✓ Branch 1 taken 49018 times.
✓ Branch 2 taken 25645 times.
✓ Branch 3 taken 51069 times.
125732 if((clk5>24)&&(clk5<52))
11172 {
11173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51069 times.
51069 if ( do_animation )tile+=20; //firing
11174
11175
4/4
✓ Branch 0 taken 27958 times.
✓ Branch 1 taken 23111 times.
✓ Branch 2 taken 25131 times.
✓ Branch 3 taken 2827 times.
51069 if(!fired&&(clk5>=38))
11176 {
11177
5/10
✓ Branch 0 taken 2827 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2827 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2827 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2827 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2827 times.
✗ Branch 9 not taken.
2827 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11178 2827 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11179 2827 sfx(wpnsfx(wpn),pan(int32_t(x)));
11180 2827 fired=true;
11181 2827 }
11182 51069 }
11183
11184 125732 break;
11185 }
11186
11187 case e1tFIREOCTO: //Fire Octo
11188 906 timer=zc_oldrand()%50+50;
11189 906 break;
11190
11191 default:
11192 26116 FireWeapon();
11193 26116 break;
11194 152754 }
11195
11196 /* Fire again if:
11197 * - clk2 about to run out
11198 * - not already double-firing (dmisc1 is 1)
11199 * - not carrying Hero
11200 * - one in 0xF chance
11201 */
11202
8/10
✓ Branch 0 taken 524932 times.
✓ Branch 1 taken 14849778 times.
✓ Branch 2 taken 4002 times.
✓ Branch 3 taken 520930 times.
✓ Branch 4 taken 4002 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4002 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3751 times.
✓ Branch 9 taken 251 times.
15374710 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11203 {
11204 #if 1
11205 251 newdir(rate, homing, grumble);
11206 #else
11207 dir^=2;
11208 #endif
11209 251 clk2=28;
11210 251 ++multishot;
11211 251 }
11212
11213
2/2
✓ Branch 0 taken 3492313 times.
✓ Branch 1 taken 11882397 times.
15374710 if(clk2==0)
11214 {
11215 11882397 multishot = 0;
11216 11882397 }
11217
11218
2/2
✓ Branch 0 taken 15310400 times.
✓ Branch 1 taken 64310 times.
15374710 if(timer) //Fire Octo
11219 {
11220 64310 clk2=15; //this keeps the octo in place until he's done firing
11221
11222
2/2
✓ Branch 0 taken 48558 times.
✓ Branch 1 taken 15752 times.
64310 if(!(timer%4))
11223 {
11224 15752 FireBreath(false);
11225 15752 }
11226
11227 64310 --timer;
11228 64310 }
11229
11230
2/2
✓ Branch 0 taken 15125317 times.
✓ Branch 1 taken 249393 times.
15374710 if(dmisc2==e2tTRIBBLE)
11231 249393 ++clk4;
11232
11233
7/10
✓ Branch 0 taken 4480 times.
✓ Branch 1 taken 15370230 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 15374017 times.
✓ Branch 4 taken 693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 693 times.
15374710 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11234 {
11235 693 int32_t kids = guys.Count();
11236 693 int32_t id2=dmisc3;
11237
11238
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 693 times.
1386 for(int32_t i=0; i<dmisc4; i++)
11239 {
11240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(addenemy(x,y,id2,-24))
11241 {
11242
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(itemguy) // Hand down the carried item
11243 {
11244 guycarryingitem = guys.Count()-1;
11245 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11246 itemguy = false;
11247 }
11248
11249 693 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11250 693 }
11251 693 }
11252
11253
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(hashero)
11254 {
11255 Hero.setEaten(0);
11256 hashero=false;
11257 }
11258
11259 693 stop_bgsfx(index);
11260 693 return true;
11261 }
11262
11263 15374017 return enemy::animate(index);
11264 15797387 }
11265
11266 16192980 void eStalfos::draw(BITMAP *dest)
11267 {
11268 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc<=0) //Submerged
11269 {
11270 clk4--; //Kludge
11271 return;
11272 }*/
11273
11274 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc>1)
11275 {
11276 cs = dcset;
11277 }*/
11278 16192980 update_enemy_frame();
11279
11280
7/8
✓ Branch 0 taken 16192554 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 16192554 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86951 times.
✓ Branch 5 taken 16105603 times.
✓ Branch 6 taken 75836 times.
✓ Branch 7 taken 11115 times.
16192980 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11281 {
11282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11115 times.
11115 if ( do_animation )tile+=20;
11283 11115 }
11284
11285 16192980 enemy::draw(dest);
11286 16192980 }
11287
11288 7492339 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11289 {
11290 7492339 int32_t tempy=yofs;
11291
11292 /*
11293 if (clk6 && dir>=left && !get_qr(qr_ENEMIESZAXIS)) {
11294 flip = 0;
11295 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11296 (clk/(frate/4)):((clk>=(frate>>1))?1:0);
11297 shadowtile = wpnsbuf[spr_shadow].tile+f2;
11298 yofs+=(((int32_t)y+17)&0xF0)-y;
11299 yofs+=8;
11300 }
11301 */
11302
4/4
✓ Branch 0 taken 7276921 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7180720 times.
✓ Branch 3 taken 311619 times.
7492339 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11303 {
11304 311619 flip = 0;
11305 311619 int32_t fdiv = frate/4;
11306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311619 times.
311619 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11307
11308
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11309 311619 efrate:((clk>=(frate>>1))?1:0);
11310 311619 shadowtile = wpnsbuf[spr_shadow].tile;
11311
11312
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 if(get_qr(qr_NEWENEMYTILES))
11313 {
11314 311619 shadowtile+=f2;
11315 311619 }
11316 else
11317 {
11318 shadowtile+=f2?1:0;
11319 }
11320
11321 311619 yofs+=shadowdistance;
11322 311619 yofs+=8;
11323 311619 }
11324
4/4
✓ Branch 0 taken 7276921 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7489304 times.
✓ Branch 3 taken 3035 times.
7492339 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11325 {
11326 3035 flip = 0;
11327 3035 int32_t fdiv = frate/4;
11328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3035 times.
3035 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11329
11330
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11331 3035 efrate:((clk>=(frate>>1))?1:0);
11332 3035 shadowtile = wpnsbuf[spr_shadow].tile;
11333
11334
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 if(get_qr(qr_NEWENEMYTILES))
11335 {
11336 3035 shadowtile+=f2;
11337 3035 }
11338 else
11339 {
11340 shadowtile+=f2?1:0;
11341 }
11342 3035 }
11343
2/2
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 7486843 times.
7492339 if(!shadow_overpit(this))
11344 7486843 enemy::drawshadow(dest, translucent);
11345 7492339 yofs=tempy;
11346 7492339 }
11347
11348 157613 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11349 {
11350 157613 int32_t wpnId = w->id;
11351 157613 int32_t wpnDir = w->dir;
11352
11353
4/4
✓ Branch 0 taken 1418 times.
✓ Branch 1 taken 156195 times.
✓ Branch 2 taken 609 times.
✓ Branch 3 taken 809 times.
157613 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11354
6/8
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 385 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265 times.
✓ Branch 5 taken 120 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 120 times.
609 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
11355
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
120 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
11356 {
11357 265 shield = false;
11358 265 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
11359
11360
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 243 times.
265 if(get_qr(qr_BRKNSHLDTILES))
11361 243 o_tile=s_tile;
11362 265 }
11363
11364 157613 int32_t ret = enemy::takehit(w,realweap);
11365
11366
4/4
✓ Branch 0 taken 22309 times.
✓ Branch 1 taken 135304 times.
✓ Branch 2 taken 20558 times.
✓ Branch 3 taken 1751 times.
157613 if(sclk && dmisc2==e2tSPLITHIT)
11367 1751 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11368
11369 157613 return ret;
11370 }
11371
11372 981551 void eStalfos::charge_attack()
11373 {
11374
2/2
✓ Branch 0 taken 6715 times.
✓ Branch 1 taken 974836 times.
981551 if(slide())
11375 6715 return;
11376
11377
10/12
✓ Branch 0 taken 974836 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 972432 times.
✓ Branch 3 taken 2404 times.
✓ Branch 4 taken 942919 times.
✓ Branch 5 taken 29513 times.
✓ Branch 6 taken 921366 times.
✓ Branch 7 taken 21553 times.
✓ Branch 8 taken 915743 times.
✓ Branch 9 taken 5623 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 915743 times.
974836 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11378 59093 return;
11379
11380
2/2
✓ Branch 0 taken 37390 times.
✓ Branch 1 taken 878353 times.
915743 if(clk3<=0)
11381 {
11382 37390 fix_coords(true);
11383
11384
2/2
✓ Branch 0 taken 10009 times.
✓ Branch 1 taken 27381 times.
37390 if(!dashing)
11385 {
11386 27381 int32_t ldir = lined_up(7,false);
11387
11388
4/4
✓ Branch 0 taken 3087 times.
✓ Branch 1 taken 24294 times.
✓ Branch 2 taken 452 times.
✓ Branch 3 taken 2635 times.
27381 if(ldir!=-1 && canmove(ldir,false))
11389 {
11390 2635 dir=ldir;
11391 2635 dashing=true;
11392
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2635 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2635 if(dmisc10<=0 || replay_version_check(0,33))
11393 2635 step=zslongToFix(dstep*100)+1;
11394 else
11395 step=zslongToFix(dmisc10*100);
11396 2635 }
11397 24746 else newdir(4,0,0);
11398 27381 }
11399
11400
2/2
✓ Branch 0 taken 35948 times.
✓ Branch 1 taken 1442 times.
37390 if(!canmove(dir,false))
11401 {
11402 1442 step=zslongToFix(dstep*100);
11403 1442 newdir();
11404 1442 dashing=false;
11405 1442 }
11406
11407 37390 zfix div = step;
11408
11409
1/2
✓ Branch 0 taken 37390 times.
✗ Branch 1 not taken.
37390 if(div == 0)
11410 div = 1;
11411
11412 37390 clk3=(int32_t)(16.0/div);
11413 37390 return;
11414 }
11415
11416 878353 move(step);
11417 878353 --clk3;
11418 981551 }
11419
11420 796110 void eStalfos::vire_hop()
11421 {
11422 //if ( sclk > 0 ) return; //Don't hop during knockback.
11423
11424 // if(dmisc9!=e9tPOLSVOICE)
11425 // {
11426 // //if( slide() /*sclk!=0*/ && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11427 // if( sclk!=0 && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11428 // return; //the enemy should split if it is sliding!
11429 // //else sclk=0; //might need this here, too. -Z
11430 // }
11431
2/2
✓ Branch 0 taken 379034 times.
✓ Branch 1 taken 417076 times.
796110 if(dmisc9!=e9tPOLSVOICE)
11432 {
11433
2/2
✓ Branch 0 taken 372449 times.
✓ Branch 1 taken 6585 times.
379034 if(sclk!=0)
11434 {
11435
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 3843 times.
6585 if (dmisc2==e2tSPLITHIT) return;
11436 //return;
11437 3843 }
11438 376292 }
11439 417076 else sclk=0;
11440
11441
8/12
✓ Branch 0 taken 793368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 777885 times.
✓ Branch 5 taken 15483 times.
✓ Branch 6 taken 761476 times.
✓ Branch 7 taken 16409 times.
✓ Branch 8 taken 761476 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 761476 times.
793368 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11442 31892 return;
11443
11444 761476 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11445 761476 int32_t jump_height = (dmisc9==e9tPOLSVOICE) ? 27 : 16;
11446
11447 761476 y=floor_y;
11448
11449
2/2
✓ Branch 0 taken 735218 times.
✓ Branch 1 taken 26258 times.
761476 if(clk3<=0)
11450 {
11451 26258 fix_coords();
11452
11453 //z=0;
11454 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11455 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11456
9/10
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 602 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 4226 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
26258 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & move_obeys_grav)))) //Vires in old quests
11457 22032 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11458
11459
2/2
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
26258 if(clk2<=0)
11460 {
11461 //z=0;
11462
6/6
✓ Branch 0 taken 19015 times.
✓ Branch 1 taken 2321 times.
✓ Branch 2 taken 18569 times.
✓ Branch 3 taken 446 times.
✓ Branch 4 taken 14491 times.
✓ Branch 5 taken 4078 times.
21336 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11463 {
11464
11465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17258 times.
17258 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11466 /*if (dmisc9==e9tPOLSVOICE )
11467 {
11468 zprint2("polsvoice jump_width is: %d\n", jump_width);
11469 zprint2("polsvoice raw step is: %d\n", step);
11470 zprint2("polsvoice step.getInt() is: %d\n", step.getInt());
11471 zprint2("setting clk2 on polsvoice to: %d\n", clk2);
11472 }
11473 else
11474 {
11475 zprint2("vire jump_width is: %d\n", jump_width);
11476 zprint2("vire raw step is: %d\n", step);
11477 zprint2("vire step.getInt() is: %d\n", step.getInt());
11478 zprint2("setting clk2 on vire to: %d\n", clk2);
11479 }
11480 */
11481 17258 }
11482 21336 }
11483
11484
4/4
✓ Branch 0 taken 12099 times.
✓ Branch 1 taken 14159 times.
✓ Branch 2 taken 5069 times.
✓ Branch 3 taken 7030 times.
26258 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11485 {
11486 7030 clk2=int32_t((16.0*jump_width)/step.getFloat());
11487 7030 }
11488
11489 26258 clk3=int32_t(16.0/step.getFloat());
11490 26258 }
11491
11492 761476 --clk3;
11493
11494
3/4
✓ Branch 0 taken 361067 times.
✓ Branch 1 taken 400409 times.
✓ Branch 2 taken 361067 times.
✗ Branch 3 not taken.
761476 if(dmisc9==e9tPOLSVOICE || clk2>0)
11495 761476 move(step);
11496
11497 761476 floor_y=y;
11498 761476 clk2--;
11499
11500 //if we're in the middle of a jump
11501
6/6
✓ Branch 0 taken 624929 times.
✓ Branch 1 taken 136547 times.
✓ Branch 2 taken 257704 times.
✓ Branch 3 taken 367225 times.
✓ Branch 4 taken 110653 times.
✓ Branch 5 taken 147051 times.
761476 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11502 {
11503 477878 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11504
11505
4/4
✓ Branch 0 taken 99298 times.
✓ Branch 1 taken 378580 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 93147 times.
477878 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11506 {
11507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93147 times.
93147 if (moveflags & move_use_fake_z) fakez=h;
11508 93147 else z=h;
11509 93147 }
11510 else
11511 {
11512 //y+=fixtoi(fixsin(itofix((clk2+1)*128*step/(16*jump_width)))*jump_height);
11513 //y-=h;
11514 384731 y=floor_y-h;
11515 384731 shadowdistance=h;
11516 }
11517 477878 }
11518 else
11519 283598 shadowdistance = 0;
11520 796110 }
11521
11522 138 void eStalfos::eathero()
11523 {
11524
5/8
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 70 times.
138 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11525 {
11526 70 hashero=true;
11527 70 y=floor_y;
11528 70 z=0;
11529
11530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(Hero.isSwimming())
11531 {
11532 Hero.setX(x);
11533 Hero.setY(y);
11534 }
11535 else
11536 {
11537 70 x=Hero.getX();
11538 70 y=Hero.getY();
11539 }
11540
11541 70 clk2=0;
11542 70 }
11543 138 }
11544
11545 1469390 bool eStalfos::WeaponOut()
11546 {
11547
2/2
✓ Branch 0 taken 2400579 times.
✓ Branch 1 taken 622399 times.
3022978 for(int32_t i=0; i<Ewpns.Count(); i++)
11548 {
11549
3/4
✓ Branch 0 taken 846991 times.
✓ Branch 1 taken 1553588 times.
✓ Branch 2 taken 846991 times.
✗ Branch 3 not taken.
2400579 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11550 {
11551 846991 return true;
11552 }
11553
11554 /*if (bgsfx > 0 && guys.idCount(id) < 2) // count self
11555 stop_sfx(bgsfx);
11556 */
11557 1553588 }
11558
11559 622399 return false;
11560 1469390 }
11561
11562 352672 void eStalfos::KillWeapon()
11563 {
11564
2/2
✓ Branch 0 taken 293384 times.
✓ Branch 1 taken 352672 times.
646056 for(int32_t i=0; i<Ewpns.Count(); i++)
11565 {
11566
4/4
✓ Branch 0 taken 245286 times.
✓ Branch 1 taken 48098 times.
✓ Branch 2 taken 244476 times.
✓ Branch 3 taken 810 times.
293384 if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang)
11567 {
11568 //only kill this Goriya's boomerang -DD
11569
2/2
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 411 times.
810 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11570 {
11571 411 Ewpns.del(i);
11572 411 }
11573 810 }
11574 293384 }
11575 352672 }
11576
11577 void eStalfos::break_shield()
11578 {
11579 if(!shield)
11580 return;
11581
11582 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
11583 shield=false;
11584
11585 if(get_qr(qr_BRKNSHLDTILES))
11586 o_tile=s_tile;
11587 }
11588
11589 13582 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11590 13582 {
11591
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 dir=(zc_oldrand()&7)+8;
11592
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 step=0;
11593 13582 movestatus=1;
11594
3/4
✓ Branch 0 taken 10458 times.
✓ Branch 1 taken 3124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10458 times.
13582 if (dmisc1 != 1 && dmisc19 > 0)
11595 {
11596 step = dmisc19/100.0;
11597 movestatus = 1;
11598 }
11599
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if (dmisc1 == 2) movestatus=2;
11600 13582 c=0;
11601 13582 clk4=0;
11602 //nets;
11603
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 init_size_flags();
11604 13582 dummy_int[1]=0;
11605 13582 }
11606
11607 3505411 bool eKeese::animate(int32_t index)
11608 {
11609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3505411 times.
3505411 if(switch_hooked) return enemy::animate(index);
11610
2/4
✓ Branch 0 taken 3505411 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3505411 times.
3505411 if(fallclk||drownclk) return enemy::animate(index);
11611
2/2
✓ Branch 0 taken 124201 times.
✓ Branch 1 taken 3381210 times.
3505411 if(dying)
11612 124201 return Dead(index);
11613
11614
2/2
✓ Branch 0 taken 3355205 times.
✓ Branch 1 taken 26005 times.
3381210 if(clk==0)
11615 {
11616 26005 removearmos(x,y,ffcactivated);
11617 26005 }
11618
11619
2/2
✓ Branch 0 taken 1025042 times.
✓ Branch 1 taken 2356168 times.
3381210 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11620 {
11621 1025042 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11622 1025042 }
11623 else
11624 {
11625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2356168 times.
2356168 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11626 2356168 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11627 }
11628
11629
2/2
✓ Branch 0 taken 120338 times.
✓ Branch 1 taken 3260872 times.
3381210 if(dmisc2 == e2tKEESETRIB)
11630 {
11631
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120338 times.
✓ Branch 2 taken 120147 times.
✓ Branch 3 taken 191 times.
120338 if(++clk4==(dmisc20>0?dmisc20:256))
11632 {
11633
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 105 times.
191 if(!m_walkflag(x,y,0, dir))
11634 {
11635 105 int32_t kids = guys.Count();
11636 105 bool success = false;
11637 105 int32_t id2=dmisc3;
11638 105 success = 0 != addenemy((zfix)x,(zfix)y,id2,-24);
11639
11640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(success)
11641 {
11642
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(itemguy) // Hand down the carried item
11643 {
11644 guycarryingitem = guys.Count()-1;
11645 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11646 itemguy = false;
11647 }
11648
11649 105 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11650 105 }
11651
11652 105 stop_bgsfx(index);
11653 105 return true;
11654 }
11655 else
11656 {
11657 86 clk4=0;
11658 }
11659 86 }
11660 120233 }
11661 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11662
3/4
✓ Branch 0 taken 845879 times.
✓ Branch 1 taken 2414993 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 845879 times.
3260872 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11663 {
11664
2/2
✓ Branch 0 taken 687068 times.
✓ Branch 1 taken 158811 times.
845879 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11665 {
11666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687068 times.
687068 if (moveflags & move_use_fake_z)
11667 {
11668 fakez=int32_t(step/zslongToFix(dstep*100));
11669 // Some variance in keese flight heights when away from Hero
11670 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11671
11672 }
11673 else
11674 {
11675 687068 z=int32_t(step/zslongToFix(dstep*100));
11676 // Some variance in keese flight heights when away from Hero
11677
2/2
✓ Branch 0 taken 503635 times.
✓ Branch 1 taken 183433 times.
687068 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11678 }
11679 687068 }
11680 else
11681 {
11682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158811 times.
158811 if (moveflags & move_use_fake_z)
11683 {
11684 fakez=int32_t(step/zslongToFix(dstep*100));
11685 // Some variance in keese flight heights when away from Hero
11686 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11687
11688 }
11689 else
11690 {
11691 158811 z=int32_t(step/zslongToFix(dstep*100));
11692 // Some variance in keese flight heights when away from Hero
11693
2/2
✓ Branch 0 taken 16841 times.
✓ Branch 1 taken 141970 times.
158811 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11694 }
11695 }
11696 845879 }
11697
11698 3381105 return enemy::animate(index);
11699 3505411 }
11700
11701 2056065 void eKeese::drawshadow(BITMAP *dest, bool translucent)
11702 {
11703 2056065 int32_t tempy=yofs;
11704 2056065 flip = 0;
11705 2056065 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11706
11707
2/2
✓ Branch 0 taken 653085 times.
✓ Branch 1 taken 1402980 times.
2056065 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
11708
2/2
✓ Branch 0 taken 690563 times.
✓ Branch 1 taken 1365502 times.
2056065 if(!get_qr(qr_ENEMIESZAXIS))
11709 {
11710 1365502 yofs+=int32_t(step/zslongToFix(dstep*10));
11711 1365502 }
11712
11713
6/6
✓ Branch 0 taken 2035375 times.
✓ Branch 1 taken 20690 times.
✓ Branch 2 taken 676820 times.
✓ Branch 3 taken 1358555 times.
✓ Branch 4 taken 661452 times.
✓ Branch 5 taken 15368 times.
2056065 if(!shadow_overpit(this) && (!get_qr(qr_ENEMIESZAXIS) || step > 0))
11714 2020007 enemy::drawshadow(dest, translucent);
11715 2056065 yofs=tempy;
11716 2056065 }
11717
11718 7885431 void eKeese::draw(BITMAP *dest)
11719 {
11720 7885431 update_enemy_frame();
11721 7885431 enemy::draw(dest);
11722 7885431 }
11723
11724 13582 void eKeese::init_size_flags()
11725 {
11726 13582 SIZEflags = d->SIZEflags;
11727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if (!(SIZEflags & OVERRIDE_HIT_X_OFFSET)) hxofs = 2;
11728
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
11729
11730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if (!(SIZEflags & OVERRIDE_HIT_WIDTH)) hit_width = 12;
11731
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13582 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
11732
11733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if (!(SIZEflags & OVERRIDE_HIT_Y_OFFSET)) hyofs = 4;
11734
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
11735
11736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if (!(SIZEflags & OVERRIDE_HIT_HEIGHT)) hit_height = 8;
11737
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13582 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
11738
11739
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13582 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11740 // al_trace("Enemy txsz:%i\n", txsz);
11741
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13582 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
11742
11743
11744
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13582 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
11745
11746
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
11747
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
11748 {
11749 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11750 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
11751 }
11752
11753
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
11754 13582 }
11755
11756 20081 void eWizzrobe::submerge(bool set)
11757 {
11758
2/2
✓ Branch 0 taken 19934 times.
✓ Branch 1 taken 147 times.
20081 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
11759 {
11760 19934 hxofs = set?1000:0;
11761 19934 return;
11762 }
11763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(submerged == set) return;
11764 147 submerged = set;
11765
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 71 times.
147 if(set)
11766 76 hxofs+=1000;
11767 71 else hxofs -= 1000;
11768 20081 }
11769 5326 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11770 5326 {
11771 5326 hxofs = 0;
11772 5326 submerged = false;
11773
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2968 times.
5326 switch(dmisc1)
11774 {
11775 case 0:
11776 2968 submerge(true);
11777 2968 fading=fade_invisible;
11778 // Set clk to just before the 'reappear' threshold
11779
9/10
✓ Branch 0 taken 2967 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2967 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1184 times.
✓ Branch 5 taken 1784 times.
✓ Branch 6 taken 1184 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1783 times.
✓ Branch 9 taken 1 times.
2968 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
11780 2968 break;
11781
11782 default:
11783 2358 dir=(loadside==right)?right:left;
11784 2358 misc=-3;
11785 2358 break;
11786 }
11787
11788 //netst+2880;
11789 5326 charging=false;
11790 5326 firing=false;
11791 5326 fclk=0;
11792
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2968 times.
5326 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
11793
1/4
✓ Branch 0 taken 5326 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5326 if (SIZEflags != 0) init_size_flags();;
11794 5326 }
11795
11796 2075375 bool eWizzrobe::animate(int32_t index)
11797 {
11798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2075375 times.
2075375 if(switch_hooked) return enemy::animate(index);
11799
2/4
✓ Branch 0 taken 2075375 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2075375 times.
2075375 if(fallclk||drownclk) return enemy::animate(index);
11800
2/2
✓ Branch 0 taken 37967 times.
✓ Branch 1 taken 2037408 times.
2075375 if(dying)
11801 {
11802 37967 return Dead(index);
11803 }
11804
11805
2/2
✓ Branch 0 taken 1970803 times.
✓ Branch 1 taken 66605 times.
2037408 if(clk==0)
11806 {
11807 66605 removearmos(x,y,ffcactivated);
11808 66605 }
11809
11810
2/2
✓ Branch 0 taken 1019220 times.
✓ Branch 1 taken 1018188 times.
2037408 if(dmisc1) // Floating
11811 {
11812 1019220 wizzrobe_attack();
11813 1019220 }
11814 else // Teleporting
11815 {
11816
5/6
✓ Branch 0 taken 1011104 times.
✓ Branch 1 taken 7084 times.
✓ Branch 2 taken 11087 times.
✓ Branch 3 taken 1000017 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11087 times.
1018188 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
11817 {
11818 7084 fading=0;
11819 7084 submerge(false);
11820 7084 solid_update(false);
11821 7084 }
11822
8/8
✓ Branch 0 taken 977386 times.
✓ Branch 1 taken 6199 times.
✓ Branch 2 taken 5284 times.
✓ Branch 3 taken 5122 times.
✓ Branch 4 taken 4977 times.
✓ Branch 5 taken 4222 times.
✓ Branch 6 taken 4084 times.
✓ Branch 7 taken 3830 times.
1011104 else switch(clk)
11823 {
11824 case 0:
11825
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 5082 times.
6199 if(!dmisc2)
11826 {
11827 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
11828 // but should not appear on dungeon walls.
11829
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 4669 times.
5082 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
11830
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4445 times.
4669 else if (editorflags&ENEMY_FLAG5)
11831 {
11832 //2.10 Windrobe
11833 //randomise location and face Hero
11834 224 int32_t t=0;
11835 224 bool placed=false;
11836
11837
4/4
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 367 times.
✓ Branch 3 taken 224 times.
591 while(!placed && t<160)
11838 {
11839
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 87 times.
367 if(isdungeon())
11840 {
11841 280 x=((zc_oldrand()%12)+2)*16;
11842 280 y=((zc_oldrand()%7)+2)*16;
11843 280 }
11844 else
11845 {
11846 87 x=((zc_oldrand()%14)+1)*16;
11847 87 y=((zc_oldrand()%9)+1)*16;
11848 }
11849
11850
6/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 224 times.
611 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11851 {
11852 224 placed=true;
11853 224 }
11854
11855 367 ++t;
11856 }
11857
11858
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 163 times.
224 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11859 {
11860
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 14 times.
61 if(y<Hero.getY())
11861 {
11862 47 dir=down;
11863 47 }
11864 else
11865 {
11866 14 dir=up;
11867 }
11868 61 }
11869 else
11870 {
11871
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 72 times.
163 if(x<Hero.getX())
11872 {
11873 72 dir=right;
11874 72 }
11875 else
11876 {
11877 91 dir=left;
11878 }
11879 }
11880
11881
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 if(!placed) // can't place him, he's gone
11882 return true;
11883
11884
11885 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
11886 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
11887 224 }
11888 4445 else place_on_axis(true, dmisc4!=0);
11889 5082 }
11890 else
11891 {
11892 1117 int32_t t=0;
11893 1117 bool placed=false;
11894
11895
4/4
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 2443 times.
✓ Branch 2 taken 2443 times.
✓ Branch 3 taken 1117 times.
3560 while(!placed && t<160)
11896 {
11897
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 1103 times.
2443 if(isdungeon())
11898 {
11899 1340 x=((zc_oldrand()%12)+2)*16;
11900 1340 y=((zc_oldrand()%7)+2)*16;
11901 1340 }
11902 else
11903 {
11904 1103 x=((zc_oldrand()%14)+1)*16;
11905 1103 y=((zc_oldrand()%9)+1)*16;
11906 }
11907
11908
6/6
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 1313 times.
✓ Branch 2 taken 898 times.
✓ Branch 3 taken 415 times.
✓ Branch 4 taken 1326 times.
✓ Branch 5 taken 1117 times.
3756 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11909 {
11910 1117 placed=true;
11911 1117 }
11912
11913 2443 ++t;
11914 }
11915
11916
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 731 times.
1117 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11917 {
11918
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 148 times.
386 if(y<Hero.getY())
11919 {
11920 238 dir=down;
11921 238 }
11922 else
11923 {
11924 148 dir=up;
11925 }
11926 386 }
11927 else
11928 {
11929
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 391 times.
731 if(x<Hero.getX())
11930 {
11931 340 dir=right;
11932 340 }
11933 else
11934 {
11935 391 dir=left;
11936 }
11937 }
11938
11939
1/2
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
1117 if(!placed) // can't place him, he's gone
11940 return true;
11941 }
11942
11943 6199 fading=fade_flicker;
11944 6199 submerge(false);
11945 6199 solid_update(false);
11946 6199 break;
11947
11948 case 64:
11949 5284 fading=0;
11950 5284 charging=true;
11951 5284 break;
11952
11953 case 73:
11954 5122 charging=false;
11955 5122 firing=40;
11956 5122 break;
11957
11958 case 83:
11959 4977 wizzrobe_attack_for_real();
11960 4977 break;
11961
11962 case 119:
11963 4222 firing=false;
11964 4222 charging=true;
11965 4222 break;
11966
11967 case 128:
11968 4084 fading=fade_flicker;
11969 4084 charging=false;
11970 4084 break;
11971
11972 case 146:
11973 3830 fading=fade_invisible;
11974 3830 submerge(true);
11975 3830 solid_update(false);
11976
11977 [[fallthrough]];
11978 default:
11979
4/4
✓ Branch 0 taken 981056 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 975008 times.
✓ Branch 3 taken 6208 times.
981216 if(clk>=(146+zc_max(0,dmisc5)))
11980 6208 clk=-1;
11981
11982 981216 break;
11983 }
11984 }
11985
11986 2037408 return enemy::animate(index);
11987 2075375 }
11988
11989 7900 void eWizzrobe::wizzrobe_attack_for_real()
11990 {
11991
1/2
✓ Branch 0 taken 7900 times.
✗ Branch 1 not taken.
7900 if(wpn==0) // Edited enemies
11992 return;
11993
11994
2/2
✓ Branch 0 taken 1983 times.
✓ Branch 1 taken 5917 times.
7900 if(dmisc2 == 0) //normal weapon
11995 {
11996 5917 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
11997 5917 sfx(firesfx, pan(int32_t(x)));
11998 5917 }
11999
2/2
✓ Branch 0 taken 995 times.
✓ Branch 1 taken 988 times.
1983 else if(dmisc2 == 1) // ring of fire
12000 {
12001 995 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
12002 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12003 995 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
12004 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12005 995 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
12006 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12007 995 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
12008 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12009 995 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
12010 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12011 995 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
12012 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12013 995 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
12014 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12015 995 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
12016 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12017 //this block of code was buggy and flat out doesn't match the default wpnsfx for these weapons.
12018 //i've compromised by making all old quest use this code chunk by default.
12019
1/2
✓ Branch 0 taken 995 times.
✗ Branch 1 not taken.
995 if (FFCore.quest_format[vGuys] < 51)
12020 {
12021 995 sfx(WAV_FIRE, pan(int32_t(x)));
12022
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 507 times.
995 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) sfx(WAV_FIRE,pan(int32_t(x)));
12023 else
12024 {
12025
3/17
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 68 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 420 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
507 switch (wpn)
12026 {
12027 19 case ewFireball: sfx(40, pan(int32_t(x))); break;
12028 case ewBrang: sfx(4, pan(int32_t(x))); break; //Ghost.zh has 0?
12029 case ewSword: sfx(20, pan(int32_t(x))); break; //Ghost.zh has 0?
12030 case ewRock: sfx(51, pan(int32_t(x))); break;
12031 68 case ewMagic: sfx(32, pan(int32_t(x))); break;
12032 case ewBomb: sfx(3, pan(int32_t(x))); break; //Ghost.zh has 0?
12033 case ewSBomb: sfx(3, pan(int32_t(x))); break; //Ghost.zh has 0?
12034 case ewLitBomb: sfx(21, pan(int32_t(x))); break; //Ghost.zh has 0?
12035 case ewLitSBomb: sfx(21, pan(int32_t(x))); break; //Ghost.zh has 0?
12036 case ewFireTrail: sfx(13, pan(int32_t(x))); break;
12037 420 case ewFlame: sfx(13, pan(int32_t(x))); break;
12038 case ewWind: sfx(32, pan(int32_t(x))); break;
12039 case ewFlame2: sfx(13, pan(int32_t(x))); break;
12040 case ewFlame2Trail: sfx(13, pan(int32_t(x))); break;
12041 case ewIce: sfx(44, pan(int32_t(x))); break;
12042 case ewFireball2: sfx(40, pan(int32_t(x))); break; //fireball (rising)
12043 default: sfx(WAV_FIRE, pan(int32_t(x))); break;
12044 }
12045 }
12046 995 }
12047 else
12048 {
12049 sfx(firesfx, pan(int32_t(x)));
12050 }
12051 995 }
12052
2/2
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 17 times.
988 else if(dmisc2==2) // summons specific enemy
12053 {
12054 971 int32_t bc=0;
12055
12056
2/2
✓ Branch 0 taken 10497 times.
✓ Branch 1 taken 971 times.
11468 for(int32_t gc=0; gc<guys.Count(); gc++)
12057 {
12058
2/2
✓ Branch 0 taken 5302 times.
✓ Branch 1 taken 5195 times.
10497 if((((enemy*)guys.spr(gc))->id) == dmisc3)
12059 {
12060 5195 ++bc;
12061 5195 }
12062 10497 }
12063
12064
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 963 times.
971 if(bc<=40)
12065 {
12066 963 int32_t kids = guys.Count();
12067 963 int32_t bats=(zc_oldrand()%3)+1;
12068
12069
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 963 times.
2928 for(int32_t i=0; i<bats; i++)
12070 {
12071 // Summon bats (or anything)
12072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(addchild(x,y,dmisc3,-10, this->script_UID))
12073 1965 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12074 1965 }
12075 963 sfx(firesfx, pan(int32_t(x)));
12076 963 }
12077 971 }
12078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 else if(dmisc2==3) //summon from layer
12079 {
12080
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(count_layer_enemies()==0)
12081 {
12082 return;
12083 }
12084
12085 17 int32_t kids = guys.Count();
12086
12087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(kids<200)
12088 {
12089 17 int32_t newguys=(zc_oldrand()%3)+1;
12090 17 bool summoned=false;
12091
12092
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 17 times.
49 for(int32_t i=0; i<newguys; i++)
12093 {
12094 32 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
12095 32 int32_t x2=0;
12096 32 int32_t y2=0;
12097
12098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 for(int32_t k=0; k<20; ++k)
12099 {
12100 36 x2=16*((zc_oldrand()%12)+2);
12101 36 y2=16*((zc_oldrand()%7)+2);
12102
12103
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 32 times.
72 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12104 {
12105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
12106 {
12107 32 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12108
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
32 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
12109 {
12110 ((enemy*)guys.spr(kids+i))->fakez = 64;
12111 ((enemy*)guys.spr(kids+i))->z = 0;
12112 }
12113 32 }
12114
12115 32 summoned=true;
12116 32 break;
12117 }
12118 4 }
12119 32 }
12120
12121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(summoned)
12122 {
12123 17 sfx(firesfx, pan(int32_t(x)));
12124 17 }
12125 17 }
12126 17 }
12127 7900 }
12128
12129
12130 1019220 void eWizzrobe::wizzrobe_attack()
12131 {
12132
10/12
✓ Branch 0 taken 982487 times.
✓ Branch 1 taken 36733 times.
✓ Branch 2 taken 982487 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 937882 times.
✓ Branch 5 taken 44605 times.
✓ Branch 6 taken 934499 times.
✓ Branch 7 taken 3383 times.
✓ Branch 8 taken 932879 times.
✓ Branch 9 taken 1620 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 932879 times.
1019220 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12133 86341 return;
12134
12135
3/8
✓ Branch 0 taken 893341 times.
✓ Branch 1 taken 39538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 893341 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
932879 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12136 {
12137 39538 fix_coords();
12138
12139
5/5
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 1050 times.
✓ Branch 2 taken 16081 times.
✓ Branch 3 taken 13008 times.
✓ Branch 4 taken 3903 times.
39538 switch(misc)
12140 {
12141 case 1: //walking
12142
2/2
✓ Branch 0 taken 10364 times.
✓ Branch 1 taken 2644 times.
13008 if(!m_walkflag(x,y,spw_door, dir))
12143 2644 misc=0;
12144 else
12145 {
12146 10364 clk3=16;
12147
12148
2/2
✓ Branch 0 taken 8966 times.
✓ Branch 1 taken 1398 times.
10364 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12149 {
12150 1398 wizzrobe_newdir(0);
12151 1398 }
12152 }
12153
12154 13008 break;
12155
12156 case 2: //phasing
12157 {
12158 3903 int32_t jx=x;
12159 3903 int32_t jy=y;
12160 3903 int32_t jdir=-1;
12161
12162
5/5
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 484 times.
✓ Branch 2 taken 472 times.
✓ Branch 3 taken 482 times.
✓ Branch 4 taken 492 times.
3903 switch(zc_oldrand()&7)
12163 {
12164 case 0:
12165 484 jx-=32;
12166 484 jy-=32;
12167 484 jdir=15;
12168 484 break;
12169
12170 case 1:
12171 472 jx+=32;
12172 472 jy-=32;
12173 472 jdir=9;
12174 472 break;
12175
12176 case 2:
12177 482 jx+=32;
12178 482 jy+=32;
12179 482 jdir=11;
12180 482 break;
12181
12182 case 3:
12183 492 jx-=32;
12184 492 jy+=32;
12185 492 jdir=13;
12186 492 break;
12187 }
12188
12189
10/10
✓ Branch 0 taken 1930 times.
✓ Branch 1 taken 1973 times.
✓ Branch 2 taken 1724 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 1597 times.
✓ Branch 5 taken 127 times.
✓ Branch 6 taken 1385 times.
✓ Branch 7 taken 212 times.
✓ Branch 8 taken 1140 times.
✓ Branch 9 taken 245 times.
3903 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12190 {
12191 1140 misc=3;
12192 1140 clk3=32;
12193 1140 dir=jdir;
12194 1140 break;
12195 }
12196 2763 }
12197 [[fallthrough]];
12198 case 3:
12199 3813 dir&=3;
12200 3813 misc=0;
12201 [[fallthrough]];
12202 case 0:
12203 19894 wizzrobe_newdir(64);
12204 [[fallthrough]];
12205 default:
12206
2/2
✓ Branch 0 taken 21886 times.
✓ Branch 1 taken 3504 times.
25390 if(!canmove(dir,(zfix)1,spw_door,false))
12207 {
12208
2/2
✓ Branch 0 taken 3265 times.
✓ Branch 1 taken 239 times.
3504 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12209 {
12210 3265 misc=1;
12211 3265 clk3=16;
12212 3265 }
12213 else
12214 {
12215 239 wizzrobe_newdir(64);
12216 239 misc=0;
12217 239 clk3=32;
12218 }
12219 3504 }
12220 else
12221 {
12222 21886 clk3=32;
12223 }
12224
12225 25390 break;
12226 }
12227
12228
2/2
✓ Branch 0 taken 35060 times.
✓ Branch 1 taken 4478 times.
39538 if(misc<0)
12229 4478 ++misc;
12230 39538 }
12231
12232 932879 --clk3;
12233
12234
3/3
✓ Branch 0 taken 248377 times.
✓ Branch 1 taken 620599 times.
✓ Branch 2 taken 63903 times.
932879 switch(misc)
12235 {
12236 case 1:
12237 case 3:
12238 248377 step=1;
12239 248377 break;
12240
12241 case 2:
12242 63903 step=0;
12243 63903 break;
12244
12245 default:
12246 620599 step=0.5;
12247 620599 break;
12248
12249 }
12250
12251 932879 move(step);
12252
12253 // if(d->misc1 && misc<=0 && clk3==28)
12254
5/6
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620599 times.
✓ Branch 3 taken 312280 times.
✓ Branch 4 taken 599052 times.
✓ Branch 5 taken 21547 times.
932879 if(dmisc1 && misc<=0 && clk3==28)
12255 {
12256
2/2
✓ Branch 0 taken 16835 times.
✓ Branch 1 taken 4712 times.
21547 if(dmisc2 != 1)
12257 {
12258
2/2
✓ Branch 0 taken 14907 times.
✓ Branch 1 taken 1928 times.
16835 if(lined_up(8,false) == dir)
12259 {
12260 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12261 // sfx(WAV_WAND,pan(int32_t(x)));
12262 1928 wizzrobe_attack_for_real();
12263 1928 fclk=30;
12264 1928 }
12265 16835 }
12266 else
12267 {
12268
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 995 times.
4712 if((zc_oldrand()%500)>=400)
12269 {
12270 995 wizzrobe_attack_for_real();
12271 995 fclk=30;
12272 995 }
12273 }
12274 21547 }
12275
12276
4/4
✓ Branch 0 taken 517526 times.
✓ Branch 1 taken 415353 times.
✓ Branch 2 taken 4050 times.
✓ Branch 3 taken 513476 times.
932879 if(misc==0 && (zc_oldrand()&127)==0)
12277 4050 misc=2;
12278
12279
4/4
✓ Branch 0 taken 67953 times.
✓ Branch 1 taken 864926 times.
✓ Branch 2 taken 64512 times.
✓ Branch 3 taken 3441 times.
932879 if(misc==2 && clk3==4)
12280 3441 fix_coords();
12281
12282
2/4
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 932879 times.
932879 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12283 {
12284
2/2
✓ Branch 0 taken 849597 times.
✓ Branch 1 taken 83282 times.
932879 if(fclk>0)
12285 {
12286 83282 --fclk;
12287 83282 }
12288 932879 }
12289
12290 1019220 }
12291
12292 21531 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12293 {
12294 // Wizzrobes shouldn't move to the edge of the screen;
12295 // if they're already there, they should move toward the center
12296
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21498 times.
21531 if(x<32)
12297 33 dir=right;
12298
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 21494 times.
21498 else if(x>=224)
12299 4 dir=left;
12300
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21492 times.
21494 else if(y<32)
12301 2 dir=down;
12302
2/2
✓ Branch 0 taken 21487 times.
✓ Branch 1 taken 5 times.
21492 else if(y>=144)
12303 5 dir=up;
12304 else
12305 21487 newdir(4,homing,spw_wizzrobe);
12306 21531 }
12307
12308 2092991 void eWizzrobe::draw(BITMAP *dest)
12309 {
12310 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12311
13/14
✓ Branch 0 taken 1042483 times.
✓ Branch 1 taken 1050508 times.
✓ Branch 2 taken 817873 times.
✓ Branch 3 taken 224610 times.
✓ Branch 4 taken 132112 times.
✓ Branch 5 taken 910371 times.
✓ Branch 6 taken 130752 times.
✓ Branch 7 taken 1360 times.
✓ Branch 8 taken 129926 times.
✓ Branch 9 taken 826 times.
✓ Branch 10 taken 125018 times.
✓ Branch 11 taken 4908 times.
✓ Branch 12 taken 125018 times.
✗ Branch 13 not taken.
2092991 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12312 125018 return;
12313
12314 1967973 int32_t tempint=dummy_int[1];
12315 1967973 bool tempbool1=dummy_bool[1];
12316 1967973 bool tempbool2=dummy_bool[2];
12317 1967973 dummy_int[1]=fclk;
12318 1967973 dummy_bool[1]=charging;
12319 1967973 dummy_bool[2]=firing;
12320 1967973 update_enemy_frame();
12321 1967973 dummy_int[1]=tempint;
12322 1967973 dummy_bool[1]=tempbool1;
12323 1967973 dummy_bool[2]=tempbool2;
12324 1967973 enemy::draw(dest);
12325 2092991 }
12326
12327 203 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12328 203 {
12329 203 fading=fade_flash_die;
12330
6/8
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 154 times.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 46 times.
203 if(dir==down&&y>=128)
12331 {
12332 3 dir=up;
12333 3 }
12334
12335
5/8
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 141 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 62 times.
203 if(dir==right&&x>=208)
12336 {
12337 dir=left;
12338 }
12339
1/4
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203 if (SIZEflags != 0) init_size_flags();;
12340 203 }
12341
12342 125855 bool eDodongo::animate(int32_t index)
12343 {
12344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125855 times.
125855 if(switch_hooked) return enemy::animate(index);
12345
2/2
✓ Branch 0 taken 3790 times.
✓ Branch 1 taken 122065 times.
125855 if(dying)
12346 {
12347 3790 return Dead(index);
12348 }
12349
12350
2/2
✓ Branch 0 taken 121496 times.
✓ Branch 1 taken 569 times.
122065 if(clk==0)
12351 {
12352 569 removearmos(x,y,ffcactivated);
12353 569 }
12354
12355
2/2
✓ Branch 0 taken 10848 times.
✓ Branch 1 taken 111217 times.
122065 if(clk2) // ate a bomb
12356 {
12357
2/2
✓ Branch 0 taken 10735 times.
✓ Branch 1 taken 113 times.
10848 if(--clk2==0)
12358 113 hp-=misc; // store bomb's power in misc
12359 10848 }
12360 else
12361 111217 constant_walk(rate,homing,spw_clipright);
12362
12363 122065 hit_width = (dir<=down) ? 16 : 32;
12364 // hysz = (dir>=left) ? 16 : 32;
12365
12366 122065 return enemy::animate(index);
12367 125855 }
12368
12369 125845 void eDodongo::draw(BITMAP *dest)
12370 {
12371 125845 tile=o_tile;
12372
12373
2/2
✓ Branch 0 taken 3065 times.
✓ Branch 1 taken 122780 times.
125845 if(clk<0)
12374 {
12375 3065 enemy::drawzcboss(dest);
12376 3065 return;
12377 }
12378
12379 122780 update_enemy_frame();
12380 122780 enemy::drawzcboss(dest);
12381
12382
2/2
✓ Branch 0 taken 51662 times.
✓ Branch 1 taken 71118 times.
122780 if(dummy_int[1]!=0) //additional tiles
12383 {
12384 71118 tile+=dummy_int[1]; //second tile is previous tile
12385 71118 xofs-=16; //new xofs change
12386 71118 enemy::drawzcboss(dest);
12387 71118 xofs+=16;
12388 71118 }
12389
12390 125845 }
12391
12392 8218 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12393 {
12394 8218 int32_t wpnId = w->id;
12395 8218 int32_t power = w->power;
12396 8218 int32_t wpnx = w->x;
12397 8218 int32_t wpny = w->y;
12398
12399
5/12
✓ Branch 0 taken 8218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8218 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2457 times.
✓ Branch 5 taken 5761 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2457 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8218 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12400 5761 return 0;
12401
12402
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 803 times.
✓ Branch 2 taken 1491 times.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
2457 switch(wpnId)
12403 {
12404 case wPhantom:
12405 return 0;
12406
12407 case wFire:
12408 case wBait:
12409 case wWhistle:
12410 case wWind:
12411 case wSSparkle:
12412 case wFSparkle:
12413 return 0;
12414
12415 case wLitBomb:
12416 case wLitSBomb:
12417
6/6
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 537 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 510 times.
✓ Branch 4 taken 690 times.
✓ Branch 5 taken 113 times.
803 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12418 690 return 0;
12419
12420 113 clk2=96;
12421 113 misc=power;
12422
12423
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 3 times.
113 if(wpnId==wLitSBomb)
12424 3 item_set=isSBOMB100;
12425
12426 113 return 1;
12427
12428 case wBomb:
12429 case wSBomb:
12430
6/6
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 1064 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 1071 times.
✓ Branch 4 taken 516 times.
✓ Branch 5 taken 975 times.
1491 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12431 516 return 0;
12432
12433 975 stunclk=160;
12434 975 misc=wpnId; // store wpnId
12435 975 return 1;
12436
12437 case wSword:
12438
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 88 times.
146 if(stunclk)
12439 {
12440 88 sfx(WAV_EHIT,pan(int32_t(x)));
12441 88 hp=0;
12442 88 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12443 88 fading=0; // don't flash
12444 88 return 1;
12445 }
12446
12447 [[fallthrough]];
12448 default:
12449 75 sfx(WAV_CHINK,pan(int32_t(x)));
12450 75 }
12451
12452 75 return 1;
12453 8218 }
12454
12455 48 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12456 48 {
12457 48 fading=fade_flash_die;
12458 //nets+5180;
12459 48 previous_dir=-1;
12460
6/8
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 13 times.
48 if(dir==down&&y>=128)
12461 {
12462 1 dir=up;
12463 1 }
12464
12465
5/8
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
48 if(dir==right&&x>=208)
12466 {
12467 dir=left;
12468 }
12469
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if (SIZEflags != 0) init_size_flags();;
12470 48 }
12471
12472 39398 bool eDodongo2::animate(int32_t index)
12473 {
12474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39398 times.
39398 if(switch_hooked) return enemy::animate(index);
12475
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 38240 times.
39398 if(dying)
12476 {
12477 1158 return Dead(index);
12478 }
12479
12480
2/2
✓ Branch 0 taken 38073 times.
✓ Branch 1 taken 167 times.
38240 if(clk==0)
12481 {
12482 167 removearmos(x,y,ffcactivated);
12483 167 }
12484
12485
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 34208 times.
38240 if(clk2) // ate a bomb
12486 {
12487
2/2
✓ Branch 0 taken 3990 times.
✓ Branch 1 taken 42 times.
4032 if(--clk2==0)
12488 42 hp-=misc; // store bomb's power in misc
12489 4032 }
12490 else
12491 34208 constant_walk(rate,homing,spw_clipbottomright);
12492
12493 38240 hit_width = (dir<=down) ? 16 : 32;
12494 38240 hit_height = (dir>=left) ? 16 : 32;
12495 38240 hxofs=(dir>=left)?-8:0;
12496 38240 hyofs=(dir<left)?-8:0;
12497
12498 38240 return enemy::animate(index);
12499 39398 }
12500
12501 39601 void eDodongo2::draw(BITMAP *dest)
12502 {
12503
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 38833 times.
39601 if(clk<0)
12504 {
12505 768 enemy::drawzcboss(dest);
12506 768 return;
12507 }
12508
12509 38833 int32_t tempx=xofs;
12510 38833 int32_t tempy=yofs;
12511 38833 update_enemy_frame();
12512 38833 enemy::drawzcboss(dest);
12513 38833 tile+=dummy_int[1]; //second tile change
12514 38833 xofs+=dummy_int[2]; //new xofs change
12515 38833 yofs+=dummy_int[3]; //new yofs change
12516 38833 enemy::drawzcboss(dest);
12517 38833 xofs=tempx;
12518 38833 yofs=tempy;
12519 39601 }
12520
12521 3929 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12522 {
12523 3929 int32_t wpnId = w->id;
12524 3929 int32_t power = w->power;
12525 3929 int32_t wpnx = w->x;
12526 3929 int32_t wpny = w->y;
12527
12528
5/8
✓ Branch 0 taken 3929 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1552 times.
✓ Branch 5 taken 2377 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1552 times.
3929 if(dying || clk<0 || clk2>0 || superman)
12529 2377 return 0;
12530
12531
5/6
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 161 times.
1552 switch(wpnId)
12532 {
12533 case wPhantom:
12534 return 0;
12535
12536 case wFire:
12537 case wBait:
12538 case wWhistle:
12539 case wWind:
12540 case wSSparkle:
12541 case wFSparkle:
12542 346 return 0;
12543
12544 case wLitBomb:
12545 case wLitSBomb:
12546
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 81 times.
321 switch(dir)
12547 {
12548 case up:
12549
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 4 times.
81 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12550 77 return 0;
12551
12552 4 break;
12553
12554 case down:
12555
4/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 6 times.
77 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12556 71 return 0;
12557
12558 6 break;
12559
12560 case left:
12561
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 16 times.
82 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12562 66 return 0;
12563
12564 16 break;
12565
12566 case right:
12567
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 16 times.
81 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12568 65 return 0;
12569
12570 16 break;
12571 }
12572
12573 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12574 // return 0;
12575 42 clk2=96;
12576 42 misc=power;
12577
12578
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(wpnId==wLitSBomb)
12579 item_set=isSBOMB100;
12580
12581 42 return 1;
12582
12583 case wBomb:
12584 case wSBomb:
12585
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 185 times.
✓ Branch 4 taken 164 times.
693 switch(dir)
12586 {
12587 case up:
12588
4/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 92 times.
176 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12589 84 return 0;
12590
12591 92 break;
12592
12593 case down:
12594
4/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 55 times.
168 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12595 113 return 0;
12596
12597 55 break;
12598
12599 case left:
12600
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 105 times.
185 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12601 80 return 0;
12602
12603 105 break;
12604
12605 case right:
12606
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 93 times.
164 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12607 71 return 0;
12608
12609 93 break;
12610 }
12611
12612 345 stunclk=160;
12613 345 misc=wpnId; // store wpnId
12614 345 return 1;
12615
12616 case wSword:
12617
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 34 times.
161 if(stunclk)
12618 {
12619 34 sfx(WAV_EHIT,pan(int32_t(x)));
12620 34 hp=0;
12621 34 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12622 34 fading=0; // don't flash
12623 34 return 1;
12624 }
12625
12626 [[fallthrough]];
12627 default:
12628 158 sfx(WAV_CHINK,pan(int32_t(x)));
12629 158 }
12630
12631 158 return 1;
12632 3929 }
12633
12634 126 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12635 126 {
12636 //these are here to bypass compiler warnings about unused arguments
12637
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if ( !(editorflags & ENEMY_FLAG5) )
12638 {
12639
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 x = dmisc1 ? 64 : 176;
12640
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 y = 64;
12641 126 }
12642 else { x = X; y = Y; }
12643
12644 //nets+5940;
12645
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 45 times.
126 if(get_qr(qr_NEWENEMYTILES))
12646 {
12647 81 }
12648 else
12649 {
12650
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 7 times.
45 if(dmisc1)
12651 {
12652 7 flip=1;
12653 7 }
12654 }
12655
12656
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12657 126 clk3=32;
12658 126 clk2=0;
12659 126 clk4=clk;
12660 126 dir=left;
12661
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if (SIZEflags != 0) init_size_flags();;
12662 126 }
12663
12664 71899 bool eAquamentus::animate(int32_t index)
12665 {
12666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71899 times.
71899 if(switch_hooked) return enemy::animate(index);
12667
2/2
✓ Branch 0 taken 2092 times.
✓ Branch 1 taken 69807 times.
71899 if(dying)
12668 2092 return Dead(index);
12669
12670 // fbx=x+((id==eRAQUAM)?4:-4);
12671
2/2
✓ Branch 0 taken 69490 times.
✓ Branch 1 taken 317 times.
69807 if(clk==0)
12672 {
12673 317 removearmos(x,y,ffcactivated);
12674 317 }
12675
12676 69807 fbx=x;
12677
12678 /*
12679 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
12680 {
12681 fbx+=16;
12682 }
12683 */
12684
2/2
✓ Branch 0 taken 69357 times.
✓ Branch 1 taken 450 times.
69807 if(--clk3==0)
12685 {
12686 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
12687 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
12688 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
12689 450 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
12690 450 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
12691 450 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
12692 450 sfx(wpnsfx(wpn),pan(int32_t(x)));
12693 450 }
12694
12695
4/4
✓ Branch 0 taken 21363 times.
✓ Branch 1 taken 48444 times.
✓ Branch 2 taken 345 times.
✓ Branch 3 taken 21018 times.
69807 if(clk3<-80 && !(zc_oldrand()&63))
12696 {
12697 345 clk3=32;
12698 345 }
12699
12700
2/2
✓ Branch 0 taken 68690 times.
✓ Branch 1 taken 1117 times.
69807 if(!((clk4+1)&63))
12701 {
12702 1117 int32_t d2=(zc_oldrand()%3)+1;
12703
12704
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 752 times.
1117 if(d2>=left)
12705 {
12706 752 dir=d2;
12707 752 }
12708
12709
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 732 times.
1117 if(dmisc1)
12710 {
12711
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 38 times.
385 if(x<=40)
12712 {
12713 38 dir=right;
12714 38 }
12715
12716
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 if(x>=104)
12717 {
12718 dir=left;
12719 }
12720 385 }
12721 else
12722 {
12723
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 21 times.
732 if(x<=136)
12724 {
12725 21 dir=right;
12726 21 }
12727
12728
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 34 times.
732 if(x>=200)
12729 {
12730 34 dir=left;
12731 34 }
12732 }
12733 1117 }
12734
12735
4/4
✓ Branch 0 taken 67907 times.
✓ Branch 1 taken 1900 times.
✓ Branch 2 taken 59366 times.
✓ Branch 3 taken 8541 times.
69807 if(clk4>=-1 && !((clk4+1)&7))
12736 {
12737
2/2
✓ Branch 0 taken 4546 times.
✓ Branch 1 taken 3995 times.
8541 if(dir==left)
12738 {
12739 4546 x-=1;
12740 4546 }
12741 else
12742 {
12743 3995 x+=1;
12744 }
12745 8541 }
12746
12747 69807 clk4=(clk4+1)%256;
12748
12749 69807 return enemy::animate(index);
12750 71899 }
12751
12752 72310 void eAquamentus::draw(BITMAP *dest)
12753 {
12754
2/2
✓ Branch 0 taken 44994 times.
✓ Branch 1 taken 27316 times.
72310 if(get_qr(qr_NEWENEMYTILES))
12755 {
12756 44994 xofs=(dmisc1?-16:0);
12757
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44994 times.
✓ Branch 2 taken 18341 times.
✓ Branch 3 taken 26653 times.
44994 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
12758
12759
2/2
✓ Branch 0 taken 1312 times.
✓ Branch 1 taken 43682 times.
44994 if(dying)
12760 {
12761 1312 xofs=0;
12762 1312 enemy::draw(dest);
12763 1312 }
12764 else
12765 {
12766 43682 drawblock(dest,15);
12767 }
12768 44994 }
12769 else
12770 {
12771 27316 int32_t xblockofs=((dmisc1)?-16:16);
12772 27316 xofs=0;
12773
12774
4/4
✓ Branch 0 taken 26634 times.
✓ Branch 1 taken 682 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 25854 times.
27316 if(clk<0 || dying)
12775 {
12776 1462 enemy::draw(dest);
12777 1462 return;
12778 }
12779
1/2
✓ Branch 0 taken 25854 times.
✗ Branch 1 not taken.
25854 if ( do_animation )
12780 {
12781 // face (0=firing, 2=resting)
12782 25854 tile=o_tile+((clk3>0)?0:2);
12783 25854 enemy::draw(dest);
12784 // tail (
12785 25854 tile=o_tile+((clk&16)?1:3);
12786 25854 xofs=xblockofs;
12787 25854 enemy::draw(dest);
12788 // body
12789 25854 yofs+=16;
12790 25854 xofs=0;
12791 25854 tile=o_tile+((clk&16)?20:22);
12792 25854 enemy::draw(dest);
12793 25854 xofs=xblockofs;
12794 25854 tile=o_tile+((clk&16)?21:23);
12795 25854 enemy::draw(dest);
12796 25854 yofs-=16;
12797 25854 }
12798 else enemy::draw(dest);
12799 }
12800 72310 }
12801
12802 23834 bool eAquamentus::hit(weapon *w)
12803 {
12804
3/6
✓ Branch 0 taken 23834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23834 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23834 times.
23834 if(!w->scriptcoldet || w->fallclk || w->drownclk) return false;
12805
12806
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 19633 times.
23834 switch(w->id)
12807 {
12808 case wBeam:
12809 case wRefBeam:
12810 case wMagic:
12811 4201 hit_height=32;
12812 4201 }
12813
12814
4/4
✓ Branch 0 taken 22740 times.
✓ Branch 1 taken 1094 times.
✓ Branch 2 taken 17546 times.
✓ Branch 3 taken 5194 times.
23834 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
12815 23834 hit_height=16;
12816 23834 return ret;
12817
12818 23834 }
12819
12820 93 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
12821 93 {
12822
12823
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if ( !(editorflags & ENEMY_FLAG5) )
12824 {
12825
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 x = 128;
12826
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 y = 48;
12827 93 }
12828 else { x = X; y = Y; }
12829
12830 93 Clk=Clk;
12831
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 if(flags & guy_fade_flicker)
12832 {
12833 clk=0;
12834 superman = 1;
12835 fading=fade_flicker;
12836 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12837 }
12838
3/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 42 times.
93 else if(flags & guy_fade_instant)
12839 {
12840 42 clk=0;
12841 42 }
12842 93 hxofs=-16;
12843 93 hit_width=48;
12844 93 clk4=0;
12845
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12846
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 dir=zc_oldrand()%3+1;
12847
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if (SIZEflags != 0) init_size_flags();;
12848
12849 //nets+5340;
12850 93 }
12851
12852 70891 bool eGohma::animate(int32_t index)
12853 {
12854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70891 times.
70891 if(switch_hooked) return enemy::animate(index);
12855
2/2
✓ Branch 0 taken 1226 times.
✓ Branch 1 taken 69665 times.
70891 if(dying)
12856 1226 return Dead(index);
12857
12858
2/2
✓ Branch 0 taken 69629 times.
✓ Branch 1 taken 36 times.
69665 if(fading)
12859 {
12860
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 if(++clk4 > 60)
12861 {
12862 35 clk4=0;
12863 35 superman=0;
12864 35 fading=0;
12865 35 clk=0;
12866
12867 35 }
12868 1 else return enemy::animate(index);
12869 35 }
12870
12871
2/2
✓ Branch 0 taken 69314 times.
✓ Branch 1 taken 350 times.
69664 if(clk==0)
12872 {
12873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 if (ffcactivated) removearmosffc(ffcactivated-1);
12874 else
12875 {
12876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 removearmos(zc_max(x-16, 0_zf),y);
12877 350 did_armos = false;
12878 350 removearmos(x,y);
12879 350 did_armos = false;
12880
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 removearmos(zc_min(x+16, 255_zf),y);
12881 }
12882 350 }
12883
12884
2/2
✓ Branch 0 taken 68878 times.
✓ Branch 1 taken 786 times.
69664 if(clk<0) return enemy::animate(index);
12885
12886 // Movement clk must be separate from animation clk because of the Clock item
12887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68878 times.
68878 if(!watch)
12888 68878 clk4++;
12889
12890
2/2
✓ Branch 0 taken 67846 times.
✓ Branch 1 taken 1032 times.
68878 if((clk4&63)==0)
12891 {
12892
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 486 times.
1032 if(clk4&64)
12893 546 dir^=1;
12894 else
12895 486 dir=zc_oldrand()%3+1;
12896 1032 }
12897
12898
2/2
✓ Branch 0 taken 67761 times.
✓ Branch 1 taken 1117 times.
68878 if((clk&63)==3)
12899 {
12900
2/2
✓ Branch 0 taken 882 times.
✓ Branch 1 taken 235 times.
1117 switch(dmisc1)
12901 {
12902 case 1:
12903 235 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
12904 235 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12905 235 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
12906 235 sfx(wpnsfx(wpn),pan(int32_t(x)));
12907 235 break;
12908
12909 default:
12910
3/4
✓ Branch 0 taken 882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 754 times.
882 if(dmisc1 != 1 && dmisc1 != 2)
12911 {
12912 754 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12913 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
12914 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
12915 754 }
12916
12917 882 break;
12918 }
12919 1117 }
12920
12921
6/6
✓ Branch 0 taken 8027 times.
✓ Branch 1 taken 60851 times.
✓ Branch 2 taken 7611 times.
✓ Branch 3 taken 416 times.
✓ Branch 4 taken 5396 times.
✓ Branch 5 taken 2215 times.
68878 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
12922 {
12923
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 1925 times.
2215 if(!(clk3%8))
12924 {
12925 290 FireBreath(true);
12926 290 }
12927 2215 }
12928
12929
2/2
✓ Branch 0 taken 34399 times.
✓ Branch 1 taken 34479 times.
68878 if(clk4&1)
12930 34479 move((zfix)1);
12931
12932
2/2
✓ Branch 0 taken 68728 times.
✓ Branch 1 taken 150 times.
68878 if(++clk3>=400)
12933 150 clk3=0;
12934
12935 68878 return enemy::animate(index);
12936 70891 }
12937
12938 70889 void eGohma::draw(BITMAP *dest)
12939 {
12940 70889 tile=o_tile;
12941
12942
4/4
✓ Branch 0 taken 70103 times.
✓ Branch 1 taken 786 times.
✓ Branch 2 taken 1226 times.
✓ Branch 3 taken 68877 times.
70889 if(clk<0 || dying)
12943 {
12944 2012 enemy::drawzcboss(dest);
12945 2012 return;
12946 }
12947
12948
2/2
✓ Branch 0 taken 53472 times.
✓ Branch 1 taken 15405 times.
68877 if(get_qr(qr_NEWENEMYTILES))
12949 {
12950 ///if ( do_animation )
12951 //Yuck. Gohma can just not have this capability right now.
12952 // left side
12953 53472 xofs=-16;
12954 53472 flip=0;
12955 // if(clk&16) tile=180;
12956 // else { tile=182; flip=1; }
12957 53472 tile+=(3*((clk&48)>>4));
12958 53472 enemy::drawzcboss(dest);
12959
12960 // right side
12961 53472 xofs=16;
12962 // tile=(180+182)-tile;
12963 53472 tile=o_tile;
12964 53472 tile+=(3*((clk&48)>>4))+2;
12965 53472 enemy::drawzcboss(dest);
12966
12967 // body
12968 53472 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
12969 53472 tile=o_tile;
12970
12971 // tile+=(3*((clk&24)>>3))+2;
12972
2/2
✓ Branch 0 taken 2975 times.
✓ Branch 1 taken 50497 times.
53472 if(clk3<16)
12973 2975 tile+=7;
12974
2/2
✓ Branch 0 taken 15890 times.
✓ Branch 1 taken 34607 times.
50497 else if(clk3<116)
12975 15890 tile+=10;
12976
2/2
✓ Branch 0 taken 2051 times.
✓ Branch 1 taken 32556 times.
34607 else if(clk3<132)
12977 2051 tile+=7;
12978 else
12979 32556 tile+=((clk3-132)&24)?4:1;
12980
12981 53472 enemy::drawzcboss(dest);
12982
12983 53472 }
12984 else
12985 {
12986 // left side
12987 15405 xofs=-16;
12988 15405 flip=0;
12989
12990
2/2
✓ Branch 0 taken 7615 times.
✓ Branch 1 taken 7790 times.
15405 if(!(clk&16))
12991 {
12992 7790 tile+=2;
12993 7790 flip=1;
12994 7790 }
12995
12996 15405 enemy::draw(dest);
12997
12998 // right side
12999 15405 tile=o_tile;
13000 15405 xofs=16;
13001
13002
2/2
✓ Branch 0 taken 7790 times.
✓ Branch 1 taken 7615 times.
15405 if((clk&16)) tile+=2;
13003
13004 // tile=(180+182)-tile;
13005 15405 enemy::draw(dest);
13006
13007 // body
13008 15405 tile=o_tile;
13009 15405 xofs=0;
13010
13011
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 14493 times.
15405 if(clk3<16)
13012 912 tile+=4;
13013
2/2
✓ Branch 0 taken 4882 times.
✓ Branch 1 taken 9611 times.
14493 else if(clk3<116)
13014 4882 tile+=5;
13015
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 9026 times.
9611 else if(clk3<132)
13016 585 tile+=4;
13017 9026 else tile+=((clk3-132)&8)?3:1;
13018
13019 15405 enemy::draw(dest);
13020
13021 }
13022 70889 }
13023
13024 578 int32_t eGohma::takehit(weapon *w, weapon* realweap)
13025 {
13026 578 int32_t wpnId = w->id;
13027 578 int32_t power = w->power;
13028 578 int32_t wpnx = w->x;
13029 578 int32_t wpnDir = w->dir;
13030 578 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
13031
13032
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 421 times.
578 if(def < 0)
13033 {
13034
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 367 times.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 364 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 36 times.
421 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
13035 {
13036 93 sfx(WAV_CHINK,pan(int32_t(x)));
13037 93 return 1;
13038 }
13039 328 }
13040
13041 485 return enemy::takehit(w, realweap);
13042 578 }
13043
13044 327 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13045 327 {
13046 327 count_enemy=(id==(id&0xFFF));
13047 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
13048
1/4
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327 if (SIZEflags != 0) init_size_flags();;
13049 327 }
13050
13051 124050 bool eLilDig::animate(int32_t index)
13052 {
13053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124050 times.
124050 if(switch_hooked) return enemy::animate(index);
13054
2/2
✓ Branch 0 taken 4410 times.
✓ Branch 1 taken 119640 times.
124050 if(dying)
13055 4410 return Dead(index);
13056
13057
2/2
✓ Branch 0 taken 7105 times.
✓ Branch 1 taken 112535 times.
119640 if(clk==0)
13058 {
13059 7105 removearmos(x,y,ffcactivated);
13060 7105 }
13061
13062
2/2
✓ Branch 0 taken 80994 times.
✓ Branch 1 taken 38646 times.
119640 if(misc<=128)
13063 {
13064
2/2
✓ Branch 0 taken 1161 times.
✓ Branch 1 taken 37485 times.
38646 if(!(++misc&31))
13065 1161 step+=0.25;
13066 38646 }
13067
13068 119640 variable_walk_8(rate,homing,hrate,spw_floater);
13069 119640 return enemy::animate(index);
13070 124050 }
13071
13072 124268 void eLilDig::draw(BITMAP *dest)
13073 {
13074 124268 tile = o_tile;
13075 // tile = 160;
13076 124268 int32_t fdiv = frate/4;
13077
1/2
✓ Branch 0 taken 124268 times.
✗ Branch 1 not taken.
124268 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13078
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13079 124268 efrate:((clk>=(frate>>1))?1:0);
13080
13081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124268 times.
124268 if ( do_animation )
13082 {
13083
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 if(get_qr(qr_NEWENEMYTILES))
13084 {
13085
9/9
✓ Branch 0 taken 11370 times.
✓ Branch 1 taken 10699 times.
✓ Branch 2 taken 10722 times.
✓ Branch 3 taken 12015 times.
✓ Branch 4 taken 10070 times.
✓ Branch 5 taken 9554 times.
✓ Branch 6 taken 8255 times.
✓ Branch 7 taken 10033 times.
✓ Branch 8 taken 8739 times.
91457 switch(dir-8) //directions get screwed up after 8. *shrug*
13086 {
13087 case up: //u
13088 11370 flip=0;
13089 11370 break;
13090
13091 case l_up: //d
13092 10699 flip=0;
13093 10699 tile+=4;
13094 10699 break;
13095
13096 case l_down: //l
13097 10722 flip=0;
13098 10722 tile+=8;
13099 10722 break;
13100
13101 case left: //r
13102 12015 flip=0;
13103 12015 tile+=12;
13104 12015 break;
13105
13106 case r_down: //ul
13107 10070 flip=0;
13108 10070 tile+=20;
13109 10070 break;
13110
13111 case down: //ur
13112 9554 flip=0;
13113 9554 tile+=24;
13114 9554 break;
13115
13116 case r_up: //dl
13117 8255 flip=0;
13118 8255 tile+=28;
13119 8255 break;
13120
13121 case right: //dr
13122 10033 flip=0;
13123 10033 tile+=32;
13124 10033 break;
13125 }
13126
13127 91457 tile+=f2;
13128 91457 }
13129 else
13130 {
13131 32811 tile+=(clk>=6)?1:0;
13132 }
13133 124268 }
13134
13135 124268 enemy::draw(dest);
13136 124268 }
13137
13138 80 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13139 80 {
13140
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 init_size_flags();
13141 80 }
13142
13143 29662 bool eBigDig::animate(int32_t index)
13144 {
13145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(switch_hooked) return enemy::animate(index);
13146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(dying)
13147 return Dead(index);
13148
13149
2/2
✓ Branch 0 taken 25558 times.
✓ Branch 1 taken 4104 times.
29662 if(clk==0)
13150 {
13151 4104 removearmos(x,y,ffcactivated);
13152 4104 }
13153
13154
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29534 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
29662 switch(misc)
13155 {
13156 case 0:
13157 29534 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13158 29534 break;
13159
13160 case 1:
13161 64 ++misc;
13162 64 break;
13163
13164 case 2:
13165
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 64 times.
175 for(int32_t i=0; i<dmisc5; i++)
13166 {
13167 111 addenemy(x,y,dmisc1+0x1000,-15);
13168 111 }
13169
13170
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc6; i++)
13171 {
13172 30 addenemy(x,y,dmisc2+0x1000,-15);
13173 30 }
13174
13175
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc7; i++)
13176 {
13177 30 addenemy(x,y,dmisc3+0x1000,-15);
13178 30 }
13179
13180
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc8; i++)
13181 {
13182 30 addenemy(x,y,dmisc4+0x1000,-15);
13183 30 }
13184
13185
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
64 if(itemguy) // Hand down the carried item
13186 {
13187 2 guycarryingitem = guys.Count()-1;
13188 2 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13189 2 itemguy = false;
13190 2 }
13191
13192 64 stop_bgsfx(index);
13193
13194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
13195
13196 64 return true;
13197 }
13198
13199 29598 return enemy::animate(index);
13200 29662 }
13201
13202 29658 void eBigDig::draw(BITMAP *dest)
13203 {
13204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if(anim!=aDIG)
13205 {
13206 update_enemy_frame();
13207 xofs-=8;
13208 yofs-=8;
13209 drawblock(dest,15);
13210 xofs+=8;
13211 yofs+=8;
13212 return;
13213 }
13214
13215 29658 tile = o_tile;
13216 29658 int32_t fdiv = frate/4;
13217
1/2
✓ Branch 0 taken 29658 times.
✗ Branch 1 not taken.
29658 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13218
13219
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13220 29658 efrate:((clk>=(frate>>1))?1:0);
13221
13222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if ( do_animation )
13223 {
13224
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 if(get_qr(qr_NEWENEMYTILES))
13225 {
13226
9/9
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 1684 times.
✓ Branch 2 taken 2031 times.
✓ Branch 3 taken 1910 times.
✓ Branch 4 taken 2041 times.
✓ Branch 5 taken 2043 times.
✓ Branch 6 taken 1514 times.
✓ Branch 7 taken 1009 times.
✓ Branch 8 taken 2241 times.
16161 switch(dir-8) //directions get screwed up after 8. *shrug*
13227 {
13228 case up: //u
13229 1688 flip=0;
13230 1688 break;
13231
13232 case l_up: //d
13233 1684 flip=0;
13234 1684 tile+=8;
13235 1684 break;
13236
13237 case l_down: //l
13238 2031 flip=0;
13239 2031 tile+=40;
13240 2031 break;
13241
13242 case left: //r
13243 1910 flip=0;
13244 1910 tile+=48;
13245 1910 break;
13246
13247 case r_down: //ul
13248 2041 flip=0;
13249 2041 tile+=80;
13250 2041 break;
13251
13252 case down: //ur
13253 2043 flip=0;
13254 2043 tile+=88;
13255
13256 2043 break;
13257
13258 case r_up: //dl
13259 1514 flip=0;
13260 1514 tile+=120;
13261 1514 break;
13262
13263 case right: //dr
13264 2241 flip=0;
13265 2241 tile+=128;
13266 2241 break;
13267 }
13268
13269 16161 tile+=(f2*2);
13270 16161 }
13271 else
13272 {
13273 13497 tile+=(f2)?0:2;
13274 13497 flip=(clk&1)?1:0;
13275 }
13276 29658 }
13277
13278 29658 xofs-=8;
13279 29658 yofs-=8;
13280 29658 drawblock(dest,15);
13281 29658 xofs+=8;
13282 29658 yofs+=8;
13283 29658 }
13284
13285 869 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13286 {
13287 869 int32_t wpnId = w->id;
13288
13289
3/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 805 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
869 if(wpnId==wWhistle && misc==0)
13290 64 misc=1;
13291
13292 869 return 0;
13293 }
13294
13295 80 void eBigDig::init_size_flags()
13296 {
13297 80 SIZEflags = d->SIZEflags;
13298
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13299 // al_trace("Enemy txsz:%i\n", txsz);
13300
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
13301
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
13302 80 else hit_width = 32;
13303
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
13304 80 else hit_height = 32;
13305
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
13306 80 else hzsz = 16; // hard to jump.
13307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
13308 80 else hxofs = -8;
13309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
13310 80 else hyofs = -8;
13311 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13312
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = d->xofs;
13313
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
13314 {
13315 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13316 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
13317 }
13318
13319
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = d->zofs;
13320 80 }
13321
13322 /*
13323 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13324 {
13325 hxofs=hyofs=8;
13326 hzsz=16; //can't be jumped.
13327 clk2=70;
13328 misc=-1;
13329 mainguy=!getmapflag();
13330 }
13331
13332 bool eGanon::animate(int32_t index)
13333 {
13334 if(switch_hooked) return enemy::animate(index);
13335 if(dying)
13336
13337 return Dead(index);
13338
13339 if(clk==0)
13340 {
13341 removearmos(x,y,ffcactivated);
13342 }
13343
13344 switch(misc)
13345 {
13346 case -1:
13347 misc=0;
13348
13349 case 0:
13350 if(++clk2>72 && !(zc_oldrand()&3))
13351 {
13352 addEwpn(x,y,z,wpn,3,wdp,dir,getUID());
13353 sfx(wpnsfx(wpn),pan(int32_t(x)));
13354 clk2=0;
13355 }
13356
13357 Stunclk=0;
13358 constant_walk(rate,homing,spw_none);
13359 break;
13360
13361 case 1:
13362 case 2:
13363 if(--Stunclk<=0)
13364 {
13365 int32_t r=zc_oldrand();
13366
13367 if(r&1)
13368 {
13369 y=96;
13370
13371 if(r&2)
13372 x=160;
13373 else
13374 x=48;
13375
13376 if(tooclose(x,y,48))
13377 x=208-x;
13378 }
13379
13380 //if ( editorflags & ENEMY_FLAG15 && current_item_id(itype_amulet,false) >= 2 ) //visible to Amulet 2
13381 //{
13382 // loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13383 // }
13384 // else
13385 // {
13386 loadpalset(csBOSS,pSprite(d->bosspal));
13387 // }
13388 misc=0;
13389 }
13390
13391 break;
13392
13393 case 3:
13394 {
13395 if(hclk>0)
13396 break;
13397
13398 misc=4;
13399 clk=0;
13400 hxofs=1000;
13401 loadpalset(9,pSprite(spPILE));
13402 music_stop();
13403 stop_sfx(WAV_ROAR);
13404
13405 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
13406
13407 sfx(WAV_GANON);
13408 //Ganon's dustpile; fall in sideview. -Z
13409 item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13410 dustpile->linked_parent = eeGANON;
13411 setmapflag();
13412 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13413 break;
13414 }
13415
13416 case 4:
13417 if(clk>=80)
13418 {
13419 misc=5;
13420
13421 if(getmapflag())
13422 {
13423 game->lvlitems[dlevel]|=liBOSS;
13424 //play_DmapMusic();
13425 playLevelMusic();
13426 return true;
13427 }
13428
13429 sfx(WAV_CLEARED);
13430 items.add(new item(x+8,y+8,(zfix)0,iBigTri,ipBIGTRI,0));
13431 setmapflag();
13432 }
13433
13434 break;
13435 }
13436
13437 //if ( editorflags & ENEMY_FLAG15 ) //visible to Amulet 2
13438 //{
13439 //if ( current_item_id(itype_amulet,false) >= 2 )
13440 //{
13441 /// loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13442 //}
13443 //}
13444
13445
13446 return enemy::animate(index);
13447 }
13448
13449
13450 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13451 {
13452 //these are here to bypass compiler warnings about unused arguments
13453 int32_t wpnId = w->id;
13454 int32_t power = w->power;
13455 int32_t enemyHitWeapon = w->parentitem;
13456
13457 switch(misc)
13458 {
13459 case 0:
13460 {
13461 //if we're not using the editor defences, and Ganon isn't hit by a sword, return.
13462 if(wpnId!=wSword && !(editorflags & ENEMY_FLAG14))
13463 return 0;
13464
13465 //if we are not using the new defences, just reduce his HP
13466 if (!(editorflags & ENEMY_FLAG14))
13467 {
13468 hp-=power;
13469 if(hp>0)
13470 {
13471 misc=1;
13472 Stunclk=64;
13473 }
13474 else
13475 {
13476 loadpalset(csBOSS,pSprite(spBROWN));
13477 misc=2;
13478 Stunclk=284;
13479 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13480 }
13481
13482 sfx(WAV_EHIT,pan(int32_t(x)));
13483
13484 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13485
13486 return 1;
13487 }
13488 //otherwise, resolve his defence.
13489 else
13490 {
13491 int32_t def = enemy::takehit(w,realweap); //This works, but it instantly kills him if it does enough damage.
13492 if(hp>0)
13493 {
13494 misc=1;
13495 Stunclk=64;
13496 }
13497 else
13498 {
13499 loadpalset(csBOSS,pSprite(spBROWN));
13500 misc=2;
13501 Stunclk=284;
13502 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13503 }
13504
13505 sfx(WAV_EHIT,pan(int32_t(x)));
13506
13507 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13508
13509
13510 return 1;
13511 }
13512 }
13513 case 2:
13514 {
13515 if
13516 (
13517 ( dmisc14 > 0 && !enemyHitWeapon == dmisc14 ) //special weapon needed to kill ganon specified in editor
13518 || //or nothing specified, use silver arrows+
13519 ( dmisc14 <= 0 && (wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4))
13520 )
13521 return 0;
13522 {
13523 misc=3;
13524 hclk=81;
13525 loadpalset(9,pSprite(spBROWN));
13526 return 1;
13527 }
13528
13529 }
13530 }
13531
13532 return 0;
13533 }
13534
13535 void eGanon::draw(BITMAP *dest)
13536 {
13537 switch(misc)
13538 {
13539 case 0:
13540 if((clk&3)==3)
13541 tile=(zc_oldrand()%5)*2+o_tile;
13542
13543 if(db!=999)
13544 break;
13545
13546 case 2:
13547 if(Stunclk<64 && (Stunclk&1) )
13548 {
13549 if
13550 (
13551 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13552 ||
13553 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13554 )
13555 {
13556 goto ganon_draw; //draw his weapons if we can see him
13557 }
13558 break;
13559 }
13560
13561 case -1:
13562 tile=o_tile;
13563
13564 //fall through
13565 case 1:
13566 case 3:
13567 ganon_draw:
13568 drawblock(dest,15);
13569 break;
13570
13571 case 4:
13572 draw_guts(dest);
13573 draw_flash(dest);
13574 break;
13575 }
13576
13577 if ( editorflags & ENEMY_FLAG1 ) //visible to Amulet 2
13578 {
13579 if
13580 (
13581 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13582 ||
13583 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13584 )
13585 {
13586 draw_guts(dest); //makes his shots visible, but not him
13587 draw_flash(dest);
13588 }
13589 }
13590 }
13591
13592 void eGanon::draw_guts(BITMAP *dest)
13593 {
13594 int32_t c = zc_min(clk>>3,8);
13595 tile = clk<24 ? 74 : 75;
13596 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
13597 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
13598 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
13599 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
13600 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
13601 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
13602 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
13603 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
13604 }
13605
13606 void eGanon::draw_flash(BITMAP *dest)
13607 {
13608
13609 int32_t c = clk-(clk>>2);
13610 cs = (frame&3)+6;
13611 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
13612 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
13613 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
13614 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
13615 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
13616 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
13617 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
13618 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
13619 }
13620 */
13621
13622 13 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13623 13 {
13624 13 hxofs=hyofs=8;
13625
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (editorflags & ENEMY_FLAG3)
13626 {
13627 hxofs = 4;
13628 hyofs = 4;
13629 hit_width = 24;
13630 hit_height = 24;
13631 SIZEflags|=OVERRIDE_HIT_WIDTH;
13632 SIZEflags|=OVERRIDE_HIT_HEIGHT;
13633 }
13634 13 hzsz=16; //can't be jumped.
13635 13 clk2=70;
13636 13 misc=-1;
13637
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 mainguy=(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN));
13638 13 }
13639
13640 18254 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
13641 {
13642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18254 times.
18254 if(dying)
13643
13644 return Dead(index);
13645
13646
2/2
✓ Branch 0 taken 18182 times.
✓ Branch 1 taken 72 times.
18254 if(clk==0)
13647 {
13648 72 removearmos(x,y,ffcactivated);
13649 72 }
13650
13651
6/7
✓ Branch 0 taken 3607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12680 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 984 times.
✓ Branch 5 taken 960 times.
✓ Branch 6 taken 10 times.
18254 switch(misc)
13652 {
13653 case -1:
13654 13 misc=0;
13655 [[fallthrough]];
13656 case 0:
13657
4/4
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 11985 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 173 times.
12693 if(++clk2>72 && !(zc_oldrand()&3))
13658 {
13659 173 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
13660 173 sfx(wpnsfx(wpn),pan(int32_t(x)));
13661 173 clk2=0;
13662 173 }
13663
13664 12693 Stunclk=0;
13665 12693 constant_walk(rate,homing,spw_none);
13666 12693 break;
13667
13668 case 1:
13669 case 2:
13670
2/2
✓ Branch 0 taken 3566 times.
✓ Branch 1 taken 41 times.
3607 if(--Stunclk<=0)
13671 {
13672 41 int32_t r=zc_oldrand();
13673
13674
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 17 times.
41 if(r&1)
13675 {
13676 17 y=96;
13677
13678
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 11 times.
17 if(r&2)
13679 6 x=160;
13680 else
13681 11 x=48;
13682
13683
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 if(tooclose(x,y,48))
13684 8 x=208-x;
13685 17 }
13686
13687 41 loadpalset(csBOSS,pSprite(d->bosspal));
13688 41 misc=0;
13689 41 }
13690
13691 3607 break;
13692
13693 case 3:
13694 {
13695
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 12 times.
984 if(hclk>0)
13696 972 break;
13697
13698 12 misc=4;
13699 12 clk=0;
13700 12 hxofs=1000;
13701 12 loadpalset(9,pSprite(spPILE));
13702 12 music_stop();
13703 12 stop_sfx(WAV_ROAR);
13704
13705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
13706
13707 12 sfx(WAV_GANON);
13708 //Ganon's dustpile; fall in sideview. -Z
13709 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13710 //dustpile->miscellaneous[31] = eeGANON;
13711
6/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
12 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13712 12 item *dustpile = NULL;
13713 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
13714 12 dustpile = (item *)items.spr(items.Count() - 1);
13715 12 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
13716 //setmapflag(); //Could be why the Triforce doesn't drop. Disabling this now. -Z ( 6th March, 2019 )
13717 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13718 12 break;
13719 }
13720
13721 case 4:
13722
2/2
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 12 times.
960 if(clk>=80)
13723 {
13724 12 misc=5;
13725
13726 //game->lvlitems[dlevel]|=liBOSS;
13727
13728 12 sfx(WAV_CLEARED);
13729 //Add the big TF over the ashes!
13730
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
36 for(word q = 0; q < items.Count(); q++)
13731 {
13732 24 item *ashes = (item*)items.spr(q);
13733
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 12 times.
24 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
13734 {
13735 //Z_scripterrlog("Found correct dustpile!\n");
13736
4/8
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
12 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
13737 12 item *bigtriforce = NULL;
13738 12 bigtriforce = (item *)items.spr(items.Count() - 1);
13739 12 bigtriforce->linked_parent = eeGANON;
13740 12 }
13741 24 }
13742 //setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13743 //game->lvlitems[dlevel]|=liBOSS; // if we had more rule bits, we could mark him dead so that he does not respawn. -Z
13744 12 }
13745
13746 960 break;
13747 10 case 5: return true;
13748 }
13749
13750 18244 return enemy::animate(index);
13751 18254 }
13752
13753
13754 964 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13755 {
13756 //these are here to bypass compiler warnings about unused arguments
13757 964 int32_t wpnId = w->id;
13758 964 int32_t power = w->power;
13759 964 int32_t enemyHitWeapon = w->parentitem;
13760
13761
3/3
✓ Branch 0 taken 714 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 166 times.
964 switch(misc)
13762 {
13763 case 0:
13764
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 53 times.
84 if(wpnId!=wSword)
13765 31 return 0;
13766
13767 53 hp-=power;
13768
13769
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 12 times.
53 if(hp>0)
13770 {
13771 41 misc=1;
13772 41 Stunclk=64;
13773 41 }
13774 else
13775 {
13776 12 loadpalset(csBOSS,pSprite(spBROWN));
13777 12 misc=2;
13778 12 Stunclk=284;
13779 12 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13780 }
13781
13782 53 sfx(WAV_EHIT,pan(int32_t(x)));
13783
13784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13785
13786 53 return 1;
13787
13788 case 2:
13789
4/6
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
166 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
13790 154 return 0;
13791
13792 12 misc=3;
13793 12 hclk=81;
13794 12 loadpalset(9,pSprite(spBROWN));
13795 12 return 1;
13796 }
13797
13798 714 return 0;
13799 964 }
13800
13801 20776 void eGanon::draw(BITMAP *dest)
13802 {
13803
6/6
✓ Branch 0 taken 3608 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 983 times.
✓ Branch 3 taken 2535 times.
✓ Branch 4 taken 12680 times.
✓ Branch 5 taken 960 times.
20776 switch(misc)
13804 {
13805 case 0:
13806
2/2
✓ Branch 0 taken 9511 times.
✓ Branch 1 taken 3169 times.
12680 if((clk&3)==3)
13807 3169 tile=(zc_oldrand()%5)*2+o_tile;
13808
13809
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
13810 {
13811
13812 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13813 {
13814 int odraw = drawstyle;
13815 drawstyle = 2;
13816 drawblock(dest,15);
13817 drawstyle = odraw;
13818 }
13819 else
13820 {
13821 drawblock(dest,15);
13822 }
13823 break;
13824
13825 }
13826
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
13827 {
13828 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13829 {
13830 int odraw = drawstyle;
13831 drawstyle = 2;
13832 drawblock(dest,15);
13833 drawstyle = odraw;
13834 }
13835 else
13836 {
13837 drawblock(dest,15);
13838 }
13839 break;
13840 }
13841
1/2
✓ Branch 0 taken 12680 times.
✗ Branch 1 not taken.
12680 if(db!=999)
13842 12680 break;
13843 [[fallthrough]];
13844 case 2:
13845
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 983 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
983 if(Stunclk<64 && (Stunclk&1))
13846 break;
13847 [[fallthrough]];
13848 case -1:
13849 3518 tile=o_tile;
13850
13851 [[fallthrough]];
13852 case 1:
13853 case 3:
13854 7126 drawblock(dest,15);
13855 7126 break;
13856
13857 case 4:
13858 960 draw_guts(dest);
13859 960 draw_flash(dest);
13860 960 break;
13861 }
13862 20776 }
13863
13864 960 void eGanon::draw_guts(BITMAP *dest)
13865 {
13866
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 204 times.
960 int32_t c = zc_min(clk>>3,8);
13867 960 tile = clk<24 ? 74 : 75;
13868 960 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
13869 960 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
13870 960 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
13871 960 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
13872 960 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
13873 960 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
13874 960 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
13875 960 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
13876 960 }
13877
13878 960 void eGanon::draw_flash(BITMAP *dest)
13879 {
13880
13881 960 int32_t c = clk-(clk>>2);
13882 960 cs = (frame&3)+6;
13883 960 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
13884 960 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
13885 960 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
13886 960 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
13887 960 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
13888 960 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
13889 960 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
13890 960 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
13891 960 }
13892
13893 15 void getBigTri(int32_t id2)
13894 {
13895 /*
13896 *************************
13897 * BIG TRIFORCE SEQUENCE *
13898 *************************
13899 0 BIGTRI out, WHITE flash in
13900 4 WHITE flash out, PILE cset white
13901 8 WHITE in
13902 ...
13903 188 WHITE out
13904 191 PILE cset red
13905 200 top SHUTTER opens
13906 209 bottom SHUTTER opens
13907 */
13908 15 sfx(itemsbuf[id2].playsound);
13909 15 guys.clear();
13910
13911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(itemsbuf[id2].flags & item_gamedata)
13912 {
13913 game->lvlitems[dlevel]|=liTRIFORCE;
13914 }
13915
13916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13917
13918 15 draw_screen(tmpscr);
13919
13920
4/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2880 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2880 times.
2895 for(int32_t f=0; f<24*8 && !Quit; f++)
13921 {
13922
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==4)
13923 {
13924
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 15 times.
240 for(int32_t i=1; i<16; i++)
13925 {
13926 225 RAMpal[CSET(9)+i]=_RGB(255,255,255);
13927 225 }
13928 15 }
13929
13930
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==0)
13931 {
13932
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 360 times.
1440 for(int32_t cs=2; cs<5; cs++)
13933 {
13934
2/2
✓ Branch 0 taken 16200 times.
✓ Branch 1 taken 1080 times.
17280 for(int32_t i=1; i<16; i++)
13935 {
13936 16200 RAMpal[CSET(cs)+i]=_RGB(255,255,255);
13937 16200 }
13938 1080 }
13939
13940 360 refreshpal=true;
13941 360 }
13942
13943
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==4)
13944 {
13945
1/2
✓ Branch 0 taken 360 times.
✗ Branch 1 not taken.
360 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
13946 else loadlvlpal(0xB);
13947 360 }
13948
13949
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==191)
13950 {
13951 15 loadpalset(9,pSprite(spPILE));
13952 15 }
13953
13954 2880 advanceframe(true);
13955 2880 }
13956
13957 //play_DmapMusic();
13958 15 playLevelMusic();
13959
13960
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
15 if(itemsbuf[id2].flags & item_flag1 && currscr < 128)
13961 {
13962 2 Hero.dowarp(1,0); //side warp
13963 2 }
13964 15 }
13965
13966 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
13967 618 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13968 618 {
13969
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if( !(editorflags & ENEMY_FLAG5) )
13970 {
13971
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 x=128;
13972
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 y=48;
13973 618 }
13974 //else { x = X; y = Y; }
13975
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 dir=(zc_oldrand()&7)+8;
13976 618 superman=1;
13977 618 fading=fade_invisible;
13978 618 hxofs=1000;
13979 618 segcnt=clk;
13980 618 segid=Id|0x1000;
13981 618 clk=0;
13982
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 id=guys.Count();
13983
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
618 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13984 618 tile=o_tile;
13985 618 hitdir = -1;
13986 618 stickclk = 0;
13987
13988 /*
13989 if (get_qr(qr_NEWENEMYTILES))
13990 {
13991 tile=nets+1220;
13992 }
13993 else
13994 {
13995 tile=57;
13996 }
13997 */
13998 618 }
13999
14000 244844 bool eMoldorm::animate(int32_t index)
14001 {
14002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(switch_hooked) return enemy::animate(index);
14003 244844 int32_t max_y = isdungeon() ? 100 : 100+28; //warning: Ugly hack. -Z
14004
2/2
✓ Branch 0 taken 216369 times.
✓ Branch 1 taken 28475 times.
244844 if ( y > (max_y) )
14005 {
14006 28475 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
14007 //Z_scripterrlog("Stickclk is %d\n", stickclk);
14008 28475 }
14009
2/2
✓ Branch 0 taken 244282 times.
✓ Branch 1 taken 562 times.
244844 if ( stickclk > 45 )
14010 {
14011 562 stickclk = 0;
14012 562 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
14013 562 }
14014
14015
14016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(clk==0)
14017 {
14018 244844 removearmos(x,y,ffcactivated);
14019 244844 }
14020
14021
2/2
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 242393 times.
244844 if(clk2)
14022 {
14023
2/2
✓ Branch 0 taken 2322 times.
✓ Branch 1 taken 129 times.
2451 if(--clk2 == 0)
14024 {
14025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(flags&guy_never_return)
14026 129 never_return(index);
14027
14028
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
14029 129 leave_item();
14030
14031 129 stop_bgsfx(index);
14032 129 return true;
14033 }
14034 2322 }
14035 else
14036 {
14037
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(stunclk>0)
14038 stunclk=0;
14039 242393 constant_walk_8_old(rate,homing,spw_floater);
14040
14041
14042 242393 misc=dir;
14043
14044 // If any higher-numbered segments were killed, segcnt can be too high,
14045 // leading to a crash
14046
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(index+segcnt>=guys.Count())
14047 segcnt=guys.Count()-index-1;
14048
14049
2/2
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 1122281 times.
1364674 for(int32_t i=index+1; i<index+segcnt+1; i++)
14050 {
14051 1122281 enemy* segment=((enemy*)guys.spr(i));
14052
14053 // More validation - if segcnt was wrong, this may not
14054 // actually be a Moldorm segment
14055
1/2
✓ Branch 0 taken 1122281 times.
✗ Branch 1 not taken.
1122281 if(segment->id!=segid)
14056 {
14057 segcnt=i-index-1;
14058 break;
14059 }
14060
14061
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1)
14062 {
14063 242669 x=segment->x;
14064 242669 y=segment->y;
14065 242669 }
14066
14067 1122281 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
14068 //Script your own blasted segmented bosses!! -Z
14069 1122281 segment->parent_script_UID = this->script_UID;
14070
4/4
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 879888 times.
✓ Branch 2 taken 24660 times.
✓ Branch 3 taken 217733 times.
1122281 if((i==index+segcnt)&&(i!=index+1)) //tail
14071 {
14072 217733 segment->dummy_int[1]=2;
14073 217733 }
14074 else
14075 {
14076 904548 segment->dummy_int[1]=1;
14077 }
14078
14079
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1) //head
14080 {
14081 242669 segment->dummy_int[1]=0;
14082 242669 }
14083
14084
2/2
✓ Branch 0 taken 1121265 times.
✓ Branch 1 taken 1016 times.
1122281 if(segment->hp <= 0)
14085 {
14086 1016 int32_t offset=1;
14087
14088
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 1480 times.
2496 for(int32_t j=i; j<index+segcnt; j++)
14089 {
14090 // Triple-check
14091
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(((enemy*)guys.spr(j+1))->id!=segid)
14092 {
14093 segcnt=j-index+1; // Add 1 because of --segcnt below
14094 break;
14095 }
14096 1480 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14097 1480 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14098 1480 }
14099
14100 1016 segment->hclk=33;
14101 1016 --segcnt;
14102 1016 --i; // Recheck the same index in case multiple segments died at once
14103 1016 }
14104 1122281 }
14105
14106
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 242264 times.
242393 if(segcnt==0)
14107 {
14108 129 clk2=19;
14109
14110 129 x=guys.spr(index+1)->x;
14111 129 y=guys.spr(index+1)->y;
14112 129 }
14113 }
14114
14115 244715 return false;
14116 244844 }
14117
14118 3150 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14119 3150 {
14120
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 if( !(editorflags & ENEMY_FLAG5) )
14121 {
14122
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 x=128;
14123
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 y=48;
14124 3150 }
14125
14126
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3150 times.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14127 3150 hyofs=4;
14128 3150 hit_width=hit_height=8;
14129 3150 hxofs=1000;
14130 3150 mainguy=count_enemy=false;
14131 3150 parentclk = 0;
14132 3150 bgsfx=-1;
14133
2/4
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 flags&=~guy_never_return;
14134 //deadsfx = WAV_EDEAD;
14135 3150 isCore = false;
14136 3150 }
14137
14138 1138024 bool esMoldorm::animate(int32_t index)
14139 {
14140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(switch_hooked) return enemy::animate(index);
14141 // Shouldn't be possible, but better to be sure
14142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(index==0)
14143 dying=true;
14144
14145
2/2
✓ Branch 0 taken 15743 times.
✓ Branch 1 taken 1122281 times.
1138024 if(dying)
14146 {
14147
1/2
✓ Branch 0 taken 15743 times.
✗ Branch 1 not taken.
15743 if(!dmisc2)
14148 15743 item_set=0;
14149
14150 15743 return Dead(index);
14151 }
14152
14153
2/2
✓ Branch 0 taken 105077 times.
✓ Branch 1 taken 1017204 times.
1122281 if(clk>=0)
14154 {
14155 1017204 hxofs=4;
14156 1017204 step=((enemy*)guys.spr(index-1))->step;
14157
14158
2/2
✓ Branch 0 taken 70455 times.
✓ Branch 1 taken 946749 times.
1017204 if(parentclk == 0)
14159 {
14160 70455 misc=dir;
14161 70455 dir=((enemy*)guys.spr(index-1))->misc;
14162 //do alignment, as in parent's animation :-/ -DD
14163 70455 x.doFloor();
14164 70455 y.doFloor();
14165 70455 }
14166
14167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(step)
14168 1017204 parentclk=(parentclk+1)%((int32_t)(8.0/step));
14169
14170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(!watch)
14171 {
14172 1017204 sprite::move(step);
14173 1017204 }
14174 1017204 }
14175
14176 1122281 return enemy::animate(index);
14177 1138024 }
14178
14179 2683 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
14180 {
14181
2/2
✓ Branch 0 taken 2230 times.
✓ Branch 1 taken 453 times.
2683 if(enemy::takehit(w,realweap))
14182 2230 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14183
14184 453 return 0;
14185 2683 }
14186
14187 1155313 void esMoldorm::draw(BITMAP *dest)
14188 {
14189 1155313 tile=o_tile;
14190 1155313 int32_t fdiv = frate/4;
14191
1/2
✓ Branch 0 taken 1155313 times.
✗ Branch 1 not taken.
1155313 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14192
14193
2/2
✓ Branch 0 taken 1043930 times.
✓ Branch 1 taken 111383 times.
1155313 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14194 1155313 efrate:((clk>=(frate>>1))?1:0);
14195
14196
2/2
✓ Branch 0 taken 111383 times.
✓ Branch 1 taken 1043930 times.
1155313 if(get_qr(qr_NEWENEMYTILES))
14197 {
14198 1043930 tile+=dummy_int[1]*40;
14199
14200
2/2
✓ Branch 0 taken 102730 times.
✓ Branch 1 taken 941200 times.
1043930 if(dir<8)
14201 {
14202 102730 flip=0;
14203
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
14204
14205
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 if(dir>3) // Skip to the next row for diagonals
14206 tile+=4;
14207 102730 }
14208 else
14209 {
14210
8/9
✓ Branch 0 taken 96530 times.
✓ Branch 1 taken 134534 times.
✓ Branch 2 taken 113426 times.
✓ Branch 3 taken 124800 times.
✓ Branch 4 taken 101314 times.
✓ Branch 5 taken 99043 times.
✓ Branch 6 taken 131794 times.
✓ Branch 7 taken 139759 times.
✗ Branch 8 not taken.
941200 switch(dir-8) //directions get screwed up after 8. *shrug*
14211 {
14212 case up: //u
14213 96530 flip=0;
14214 96530 break;
14215
14216 case l_up: //d
14217 134534 flip=0;
14218 134534 tile+=4;
14219 134534 break;
14220
14221 case l_down: //l
14222 113426 flip=0;
14223 113426 tile+=8;
14224 113426 break;
14225
14226 case left: //r
14227 124800 flip=0;
14228 124800 tile+=12;
14229 124800 break;
14230
14231 case r_down: //ul
14232 101314 flip=0;
14233 101314 tile+=20;
14234 101314 break;
14235
14236 case down: //ur
14237 99043 flip=0;
14238 99043 tile+=24;
14239 99043 break;
14240
14241 case r_up: //dl
14242 131794 flip=0;
14243 131794 tile+=28;
14244 131794 break;
14245
14246 case right: //dr
14247 139759 flip=0;
14248 139759 tile+=32;
14249 139759 break;
14250 }
14251 }
14252
14253 1043930 tile+=f2;
14254 1043930 }
14255
14256
2/2
✓ Branch 0 taken 106267 times.
✓ Branch 1 taken 1049046 times.
1155313 if(clk>=0)
14257 1049046 enemy::draw(dest);
14258 1155313 }
14259
14260 420 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14261 420 {
14262
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if( !(editorflags & ENEMY_FLAG5) )
14263 {
14264
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 x=64;
14265
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 y=80;
14266 420 }
14267 //else { x = X; y = Y; }
14268 //byte legaldirs = 0;
14269 420 int32_t incr = 16;
14270 //int32_t possiiblepos = 0;
14271 //int32_t positions[8] = {0};
14272
14273 //Don't spawn in pits.
14274
5/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 315 times.
✓ Branch 7 taken 105 times.
420 if ( m_walkflag_simple(x, y) )
14275 {
14276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 for ( ; incr < 240; incr += 16 )
14277 {
14278 //move if we spawn over a pit
14279 //check each direction
14280
7/12
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 139 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 135 times.
139 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14281 {
14282
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
14283 }
14284
7/12
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 39 times.
✓ Branch 11 taken 96 times.
135 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14285 {
14286
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 x+=incr; break;
14287 }
14288
9/16
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 96 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 96 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 96 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 64 times.
96 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14289 {
14290
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
14291 }
14292
9/16
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 64 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 64 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 60 times.
64 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14293 {
14294
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 x+=incr; y-=incr; break;
14295 }
14296
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14297 {
14298 y -= incr; break;
14299 }
14300
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14301 {
14302 y+=incr; break;
14303 }
14304
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14305 {
14306
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
14307 }
14308
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14309 {
14310 x+=incr; y+=incr; break;
14311 }
14312 34 else continue;
14313
14314 }
14315
14316 105 }
14317
14318 420 dir=up;
14319 420 superman=1;
14320 420 fading=fade_invisible;
14321 420 hxofs=1000;
14322 420 segcnt=clk;
14323 420 clk=0;
14324 //set up move history
14325
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 3060 times.
3480 for(int32_t i=0; i <= (1<<dmisc2); i++)
14326
3/6
✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3060 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3060 times.
✗ Branch 5 not taken.
3060 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14327 420 }
14328
14329 236907 bool eLanmola::animate(int32_t index)
14330 {
14331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236907 times.
236907 if(switch_hooked) return enemy::animate(index);
14332
2/2
✓ Branch 0 taken 196711 times.
✓ Branch 1 taken 40196 times.
236907 if(clk==0)
14333 {
14334 40196 removearmos(x,y,ffcactivated);
14335 40196 }
14336
14337
2/2
✓ Branch 0 taken 3591 times.
✓ Branch 1 taken 233316 times.
236907 if(clk2)
14338 {
14339
2/2
✓ Branch 0 taken 3402 times.
✓ Branch 1 taken 189 times.
3591 if(--clk2 == 0)
14340 {
14341
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 103 times.
189 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
14342 86 leave_item();
14343
14344 189 stop_bgsfx(index);
14345 189 return true;
14346 }
14347
14348 3402 return false;
14349 }
14350
14351
14352 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
14353 //the direction AND x,y position of the lanmola to vary in uncertain ways.
14354 //I've added a complete movement history to this enemy to compensate -DD
14355 233316 constant_walk(rate,homing,spw_none);
14356 233316 prevState.pop_front();
14357 233316 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
14358
14359 // This could cause a crash with Moldorms. I didn't see the same problem
14360 // with Lanmolas, but it looks like it ought to be possible, so here's
14361 // the same solution. - Saf
14362
1/2
✓ Branch 0 taken 233316 times.
✗ Branch 1 not taken.
233316 if(index+segcnt>=guys.Count())
14363 segcnt=guys.Count()-index-1;
14364
14365
2/2
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 966396 times.
1199712 for(int32_t i=index+1; i<index+segcnt+1; i++)
14366 {
14367 966396 enemy* segment=((enemy*)guys.spr(i));
14368
14369 // More validation in case segcnt is wrong
14370
1/2
✓ Branch 0 taken 966396 times.
✗ Branch 1 not taken.
966396 if((segment->id&0xFFF)!=(id&0xFFF))
14371 {
14372 segcnt=i-index-1;
14373 break;
14374 }
14375
14376 966396 segment->o_tile=o_tile;
14377 966396 segment->parent_script_UID = this->script_UID;
14378
4/4
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 733080 times.
✓ Branch 2 taken 37616 times.
✓ Branch 3 taken 195700 times.
966396 if((i==index+segcnt)&&(i!=index+1))
14379 {
14380 195700 segment->dummy_int[1]=1; //tail
14381 195700 }
14382 else
14383 {
14384 770696 segment->dummy_int[1]=0;
14385 }
14386
14387
2/2
✓ Branch 0 taken 965227 times.
✓ Branch 1 taken 1169 times.
966396 if(segment->hp <= 0)
14388 {
14389
2/2
✓ Branch 0 taken 1169 times.
✓ Branch 1 taken 1961 times.
3130 for(int32_t j=i; j<index+segcnt; j++)
14390 {
14391 // Triple-check
14392
1/2
✓ Branch 0 taken 1961 times.
✗ Branch 1 not taken.
1961 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14393 {
14394 segcnt=j-index+1; // Add 1 because of --segcnt below
14395 break;
14396 }
14397 1961 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14398 1961 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14399 1961 }
14400
14401 1169 ((enemy*)guys.spr(i))->hclk=33;
14402 1169 --segcnt;
14403 1169 --i; // Recheck the same index in case multiple segments died at once
14404 1169 }
14405 966396 }
14406
14407
2/2
✓ Branch 0 taken 233127 times.
✓ Branch 1 taken 189 times.
233316 if(segcnt==0)
14408 {
14409 189 clk2=19;
14410 189 x=guys.spr(index+1)->x;
14411 189 y=guys.spr(index+1)->y;
14412 189 setmapflag(mTMPNORET);
14413 189 }
14414
14415 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14416 //which is... disastrous.
14417 233316 hp = 1;
14418 233316 return enemy::animate(index);
14419 236907 }
14420
14421 2267 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14422 2267 {
14423
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 if( !(editorflags & ENEMY_FLAG5) )
14424 {
14425
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 x=64;
14426
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 y=80;
14427 2267 }
14428 2267 int32_t incr = 16;
14429 //Don't spawn in pits.
14430
5/8
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2267 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1742 times.
✓ Branch 7 taken 525 times.
2267 if ( m_walkflag_simple(x, y) )
14431 {
14432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 for ( ; incr < 240; incr += 16 )
14433 {
14434 //move if we spawn over a pit
14435 //check each direction
14436
7/12
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 695 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 695 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 695 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 695 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 675 times.
695 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14437 {
14438
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14439 }
14440
7/12
✓ Branch 0 taken 675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 675 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 675 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 675 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 195 times.
✓ Branch 11 taken 480 times.
675 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14441 {
14442
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 x+=incr; break;
14443 }
14444
9/16
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 480 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 480 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 480 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 480 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 480 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 320 times.
480 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14445 {
14446
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14447 }
14448
9/16
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 320 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 320 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 320 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 320 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 320 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20 times.
✓ Branch 15 taken 300 times.
320 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14449 {
14450
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 x+=incr; y-=incr; break;
14451 }
14452
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14453 {
14454 y -= incr; break;
14455 }
14456
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14457 {
14458 y+=incr; break;
14459 }
14460
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14461 {
14462
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14463 }
14464
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14465 {
14466 x+=incr; y+=incr; break;
14467 }
14468 170 else continue;
14469
14470 }
14471
14472 525 }
14473
14474 2267 hxofs=1000;
14475 2267 hit_width=8;
14476 2267 mainguy=false;
14477 2267 count_enemy=(id<0x2000)?true:false;
14478
14479 //set up move history
14480
2/2
✓ Branch 0 taken 2267 times.
✓ Branch 1 taken 16763 times.
19030 for(int32_t i=0; i <= (1<<dmisc2); i++)
14481
3/6
✓ Branch 0 taken 16763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16763 times.
✗ Branch 5 not taken.
16763 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14482
14483 2267 bgsfx = -1;
14484 2267 isCore = false;
14485
2/4
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
2267 flags&=~guy_never_return;
14486 2267 }
14487
14488 985563 bool esLanmola::animate(int32_t index)
14489 {
14490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985563 times.
985563 if(switch_hooked) return enemy::animate(index);
14491 // Shouldn't be possible, but who knows
14492
2/2
✓ Branch 0 taken 985545 times.
✓ Branch 1 taken 18 times.
985563 if(index==0)
14493 18 dying=true;
14494
14495
2/2
✓ Branch 0 taken 19167 times.
✓ Branch 1 taken 966396 times.
985563 if(dying)
14496 {
14497 19167 xofs=0;
14498
14499
2/2
✓ Branch 0 taken 9861 times.
✓ Branch 1 taken 9306 times.
19167 if(!dmisc3)
14500 9306 item_set=0;
14501
14502 19167 return Dead(index);
14503 }
14504
14505
2/2
✓ Branch 0 taken 35946 times.
✓ Branch 1 taken 930450 times.
966396 if(clk>=0)
14506 {
14507 930450 hxofs=4;
14508
14509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930450 times.
930450 if(!watch)
14510 {
14511 930450 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14512 930450 prevState.pop_front();
14513 930450 prevState.push_back(newstate);
14514 930450 x = newstate.first.first;
14515 930450 y = newstate.first.second;
14516 930450 dir = newstate.second;
14517 930450 }
14518 930450 }
14519
14520 966396 return enemy::animate(index);
14521 985563 }
14522
14523 2655 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14524 {
14525
2/2
✓ Branch 0 taken 2065 times.
✓ Branch 1 taken 590 times.
2655 if(enemy::takehit(w,realweap))
14526 2065 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14527
14528 590 return 0;
14529 2655 }
14530
14531 990931 void esLanmola::draw(BITMAP *dest)
14532 {
14533 990931 tile=o_tile;
14534 990931 int32_t fdiv = frate/4;
14535
1/2
✓ Branch 0 taken 990931 times.
✗ Branch 1 not taken.
990931 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14536
14537
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14538 990931 efrate:((clk>=(frate>>1))?1:0);
14539
14540
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 if(get_qr(qr_NEWENEMYTILES))
14541 {
14542
2/2
✓ Branch 0 taken 147165 times.
✓ Branch 1 taken 481767 times.
628932 if(id>=0x2000)
14543 {
14544 481767 tile+=20;
14545
14546
2/2
✓ Branch 0 taken 353025 times.
✓ Branch 1 taken 128742 times.
481767 if(dummy_int[1]==1)
14547 {
14548 128742 tile+=20;
14549 128742 }
14550 481767 }
14551
14552
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 141419 times.
✓ Branch 2 taken 140994 times.
✓ Branch 3 taken 159500 times.
✓ Branch 4 taken 187019 times.
628932 switch(dir)
14553 {
14554 case up:
14555 141419 flip=0;
14556 141419 break;
14557
14558 case down:
14559 140994 flip=0;
14560 140994 tile+=4;
14561 140994 break;
14562
14563 case left:
14564 159500 flip=0;
14565 159500 tile+=8;
14566 159500 break;
14567
14568 case right:
14569 187019 flip=0;
14570 187019 tile+=12;
14571 187019 break;
14572 }
14573
14574 628932 tile+=f2;
14575 628932 }
14576 else
14577 {
14578
2/2
✓ Branch 0 taken 90543 times.
✓ Branch 1 taken 271456 times.
361999 if(id>=0x2000)
14579 {
14580 271456 tile+=1;
14581 271456 }
14582 }
14583
14584
2/2
✓ Branch 0 taken 37038 times.
✓ Branch 1 taken 953893 times.
990931 if(clk>=0)
14585 953893 enemy::draw(dest);
14586 990931 }
14587
14588 150 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
14589 150 {
14590 //these are here to bypass compiler warnings about unused arguments
14591 150 Clk=Clk;
14592 150 superman=1;
14593
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 dir=(zc_oldrand()&7)+8;
14594 150 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
14595
14596
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 150 times.
842 for(int32_t i=0; i<armcnt; i++)
14597 692 arm[i]=i;
14598
14599 150 fading=fade_blue_poof;
14600 //nets+4680;
14601 150 adjusted=false;
14602
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if (SIZEflags != 0) init_size_flags();;
14603 150 }
14604
14605 66494 bool eManhandla::animate(int32_t index)
14606 {
14607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66494 times.
66494 if(switch_hooked) return enemy::animate(index);
14608
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 65112 times.
66494 if(dying)
14609 1382 return Dead(index);
14610
14611
2/2
✓ Branch 0 taken 62641 times.
✓ Branch 1 taken 2471 times.
65112 if(clk==0)
14612 {
14613 2471 removearmos(x,y,ffcactivated);
14614 2471 }
14615
14616
14617 // check arm status, move dead ones to end of group
14618
2/2
✓ Branch 0 taken 193618 times.
✓ Branch 1 taken 65112 times.
258730 for(int32_t i=0; i<armcnt; i++)
14619 {
14620 193618 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
14621
3/4
✓ Branch 0 taken 193618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 424 times.
✓ Branch 3 taken 193194 times.
193618 if(!cur_arm || cur_arm->dying)
14622 {
14623
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 424 times.
976 for(int32_t j=i; j<armcnt-1; j++)
14624 {
14625 552 zc_swap(arm[j],arm[j+1]);
14626 552 guys.swap(index+j+1,index+j+2);
14627 552 }
14628
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 87 times.
424 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
14629 {
14630 87 leave_item();
14631 87 }
14632 424 --armcnt;
14633 424 --i;
14634 424 continue;
14635 }
14636
2/2
✓ Branch 0 taken 192502 times.
✓ Branch 1 taken 692 times.
193194 if(!adjusted)
14637 {
14638
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 184 times.
692 if(!dmisc2)
14639 {
14640 508 cur_arm->o_tile=o_tile+40;
14641 508 cur_arm->parent_script_UID = this->script_UID;
14642 508 }
14643 else
14644 {
14645 184 cur_arm->o_tile=o_tile+160;
14646 184 cur_arm->parent_script_UID = this->script_UID;
14647 }
14648 692 }
14649 193194 }
14650
14651 65112 adjusted=true;
14652
14653 // move or die
14654
2/2
✓ Branch 0 taken 65029 times.
✓ Branch 1 taken 83 times.
65112 if(armcnt==0)
14655 83 hp=0;
14656 else
14657 {
14658 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
14659
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
14660
1/2
✓ Branch 0 taken 65029 times.
✗ Branch 1 not taken.
65029 if (step > 4.5_zf) step = 4.5_zf;
14661 65029 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
14662
14663
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 if(!dmisc2)
14664 {
14665
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 53584 times.
204603 for(int32_t i=0; i<armcnt; i++)
14666 {
14667
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14668 {
14669 case 0:
14670 38579 dy1=-24;
14671 38579 break;
14672
14673 case 1:
14674 36328 dy2=31;
14675 36328 break;
14676
14677 case 2:
14678 36250 dx1=-16;
14679 36250 break;
14680
14681 case 3:
14682 39862 dx2=31;
14683 39862 break;
14684 }
14685 151019 }
14686 53584 }
14687 else
14688 {
14689 11445 dx1=-8, dy1=-16, dx2=23, dy2=23;
14690
14691
2/2
✓ Branch 0 taken 42175 times.
✓ Branch 1 taken 11445 times.
53620 for(int32_t i=0; i<armcnt; i++)
14692 {
14693
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12012 times.
✓ Branch 2 taken 7730 times.
✓ Branch 3 taken 9837 times.
✓ Branch 4 taken 12596 times.
42175 switch(arm[i]&3)
14694 {
14695 case 0:
14696 12012 dy1=-32;
14697 12012 break;
14698
14699 case 1:
14700 7730 dy2=39;
14701 7730 break;
14702
14703 case 2:
14704 9837 dx1=-24;
14705 9837 break;
14706
14707 case 3:
14708 12596 dx2=39;
14709 12596 break;
14710 }
14711 42175 }
14712 }
14713
14714 65029 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
14715
14716
2/2
✓ Branch 0 taken 193194 times.
✓ Branch 1 taken 65029 times.
258223 for(int32_t i=0; i<armcnt; i++)
14717 {
14718 193194 zfix dx=(zfix)0,dy=(zfix)0;
14719
14720
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 42175 times.
193194 if(!dmisc2)
14721 {
14722
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14723 {
14724 case 0:
14725 38579 dy=-16;
14726 38579 break;
14727
14728 case 1:
14729 36328 dy=16;
14730 36328 break;
14731
14732 case 2:
14733 36250 dx=-16;
14734 36250 break;
14735
14736 case 3:
14737 39862 dx=16;
14738 39862 break;
14739 }
14740 151019 }
14741 else
14742 {
14743
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5447 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 4163 times.
✓ Branch 4 taken 6774 times.
✓ Branch 5 taken 6565 times.
✓ Branch 6 taken 3744 times.
✓ Branch 7 taken 5674 times.
✓ Branch 8 taken 5822 times.
42175 switch(arm[i])
14744 {
14745 case 0:
14746 5447 dy=-24;
14747 5447 dx=-8;
14748 5447 break;
14749
14750 case 1:
14751 3986 dy=24;
14752 3986 dx=8;
14753 3986 break;
14754
14755 case 2:
14756 4163 dx=-24;
14757 4163 dy=8;
14758 4163 break;
14759
14760 case 3:
14761 6774 dx=24;
14762 6774 dy=-8;
14763 6774 break;
14764
14765 case 4:
14766 6565 dy=-24;
14767 6565 dx=8;
14768 6565 break;
14769
14770 case 5:
14771 3744 dy=24;
14772 3744 dx=-8;
14773 3744 break;
14774
14775 case 6:
14776 5674 dx=-24;
14777 5674 dy=-8;
14778 5674 break;
14779
14780 case 7:
14781 5822 dx=24;
14782 5822 dy=8;
14783 5822 break;
14784 }
14785 }
14786
14787 193194 guys.spr(index+i+1)->x = x+dx;
14788 193194 guys.spr(index+i+1)->y = y+dy;
14789 193194 }
14790 }
14791
14792 65112 return enemy::animate(index);
14793 66494 }
14794
14795
14796 1751 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
14797 {
14798 1751 int32_t wpnId = w->id;
14799
14800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1751 times.
1751 if(dying)
14801 return 0;
14802
14803
3/4
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
1751 switch(wpnId)
14804 {
14805 case wBomb:
14806 case wSBomb:
14807 case wSword:
14808 case wHammer:
14809 case wWand:
14810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
786 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
14811
14812 case wLitBomb:
14813 case wLitSBomb:
14814 case wBait:
14815 case wWhistle:
14816 case wFire:
14817 case wWind:
14818 case wSSparkle:
14819 case wFSparkle:
14820 case wPhantom:
14821 1709 return 0;
14822
14823 case wHookshot:
14824 case wBrang:
14825 sfx(WAV_CHINK,pan(int32_t(x)));
14826 break;
14827
14828 default:
14829
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
14830 else sfx(WAV_CHINK,pan(int32_t(x)));
14831
14832 42 }
14833
14834 42 return 1;
14835 1751 }
14836
14837 66490 void eManhandla::draw(BITMAP *dest)
14838 {
14839 66490 tile=o_tile;
14840 66490 int32_t fdiv = frate/4;
14841
1/2
✓ Branch 0 taken 66490 times.
✗ Branch 1 not taken.
66490 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14842
14843
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14844 66490 efrate:((clk>=(frate>>1))?1:0);
14845
14846
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 if(get_qr(qr_NEWENEMYTILES))
14847 {
14848
2/2
✓ Branch 0 taken 11308 times.
✓ Branch 1 taken 37494 times.
48802 if(!dmisc2)
14849 {
14850
8/9
✓ Branch 0 taken 4771 times.
✓ Branch 1 taken 4640 times.
✓ Branch 2 taken 4995 times.
✓ Branch 3 taken 5574 times.
✓ Branch 4 taken 3793 times.
✓ Branch 5 taken 3930 times.
✓ Branch 6 taken 3908 times.
✓ Branch 7 taken 5883 times.
✗ Branch 8 not taken.
37494 switch(dir-8) //directions get screwed up after 8. *shrug*
14851 {
14852 case up: //u
14853 4771 flip=0;
14854 4771 break;
14855
14856 case l_up: //d
14857 4640 flip=0;
14858 4640 tile+=4;
14859 4640 break;
14860
14861 case l_down: //l
14862 4995 flip=0;
14863 4995 tile+=8;
14864 4995 break;
14865
14866 case left: //r
14867 5574 flip=0;
14868 5574 tile+=12;
14869 5574 break;
14870
14871 case r_down: //ul
14872 3793 flip=0;
14873 3793 tile+=20;
14874 3793 break;
14875
14876 case down: //ur
14877 3930 flip=0;
14878 3930 tile+=24;
14879 3930 break;
14880
14881 case r_up: //dl
14882 3908 flip=0;
14883 3908 tile+=28;
14884 3908 break;
14885
14886 case right: //dr
14887 5883 flip=0;
14888 5883 tile+=32;
14889 5883 break;
14890 }
14891
14892 37494 tile+=f2;
14893 37494 enemy::draw(dest);
14894 37494 } //manhandla 2, big body
14895 else
14896 {
14897
14898
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1277 times.
✓ Branch 2 taken 1360 times.
✓ Branch 3 taken 2242 times.
✓ Branch 4 taken 1789 times.
✓ Branch 5 taken 1345 times.
✓ Branch 6 taken 805 times.
✓ Branch 7 taken 948 times.
✓ Branch 8 taken 1542 times.
11308 switch(dir-8) //directions get screwed up after 8. *shrug*
14899 {
14900 case up: //u
14901 1277 flip=0;
14902 1277 break;
14903
14904 case l_up: //d
14905 1360 flip=0;
14906 1360 tile+=8;
14907 1360 break;
14908
14909 case l_down: //l
14910 2242 flip=0;
14911 2242 tile+=40;
14912 2242 break;
14913
14914 case left: //r
14915 1789 flip=0;
14916 1789 tile+=48;
14917 1789 break;
14918
14919 case r_down: //ul
14920 1345 flip=0;
14921 1345 tile+=80;
14922 1345 break;
14923
14924 case down: //ur
14925 805 flip=0;
14926 805 tile+=88;
14927 805 break;
14928
14929 case r_up: //dl
14930 948 flip=0;
14931 948 tile+=120;
14932 948 break;
14933
14934 case right: //dr
14935 1542 flip=0;
14936 1542 tile+=128;
14937 1542 break;
14938 }
14939
14940 11308 tile+=(f2*2);
14941 11308 xofs-=8;
14942 11308 yofs-=8;
14943 11308 drawblock(dest,15);
14944 11308 xofs+=8;
14945 11308 yofs+=8;
14946 }
14947 48802 }
14948 else
14949 {
14950
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 17173 times.
17688 if(!dmisc2)
14951 {
14952 17173 enemy::draw(dest);
14953 17173 }
14954 else
14955 {
14956 515 xofs-=8;
14957 515 yofs-=8;
14958 515 enemy::draw(dest);
14959 515 xofs+=16;
14960 515 enemy::draw(dest);
14961 515 yofs+=16;
14962 515 enemy::draw(dest);
14963 515 xofs-=16;
14964 515 enemy::draw(dest);
14965 515 xofs+=8;
14966 515 yofs-=8;
14967 }
14968 }
14969 66490 }
14970
14971 692 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14972 692 {
14973 692 id=misc=clk;
14974 692 dir = clk & 3;
14975 692 clk=0;
14976 692 mainguy=count_enemy=false;
14977 692 dummy_bool[0]=false;
14978 692 item_set=0;
14979 692 bgsfx=-1;
14980 692 deadsfx = WAV_EDEAD;
14981
2/4
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 692 times.
✗ Branch 3 not taken.
692 flags &= (~guy_never_return);
14982 692 isCore = false;
14983
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if (SIZEflags != 0) init_size_flags();;
14984 692 }
14985
14986 200202 bool esManhandla::animate(int32_t index)
14987 {
14988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200202 times.
200202 if(switch_hooked) return enemy::animate(index);
14989
2/2
✓ Branch 0 taken 7008 times.
✓ Branch 1 taken 193194 times.
200202 if(dying)
14990 7008 return Dead(index);
14991
14992
2/2
✓ Branch 0 taken 12404 times.
✓ Branch 1 taken 180790 times.
193194 if(clk==0)
14993 {
14994 12404 removearmos(x,y,ffcactivated);
14995 12404 }
14996
14997
2/2
✓ Branch 0 taken 165298 times.
✓ Branch 1 taken 27896 times.
193194 if(--clk2<=0)
14998 {
14999 27896 clk2=unsigned(zc_oldrand())%5+5;
15000 27896 clk3^=1;
15001 27896 }
15002
15003
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 191703 times.
193194 if(!(zc_oldrand()&127))
15004 {
15005 1491 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
15006 1491 sfx(wpnsfx(wpn),pan(int32_t(x)));
15007 1491 }
15008
15009 193194 return enemy::animate(index);
15010 200202 }
15011
15012 200186 void esManhandla::draw(BITMAP *dest)
15013 {
15014 200186 tile=o_tile;
15015 200186 int32_t fdiv = frate/4;
15016
1/2
✓ Branch 0 taken 200186 times.
✗ Branch 1 not taken.
200186 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15017
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 int32_t f2=get_qr(qr_NEWENEMYTILES)?
15018 200186 efrate:((clk>=(frate>>1))?1:0);
15019
15020
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 if(get_qr(qr_NEWENEMYTILES))
15021 {
15022
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 39945 times.
✓ Branch 2 taken 36845 times.
✓ Branch 3 taken 39966 times.
✓ Branch 4 taken 41960 times.
158716 switch(misc&3)
15023 {
15024 case up:
15025 39945 break;
15026
15027 case down:
15028 36845 tile+=4;
15029 36845 break;
15030
15031 case left:
15032 39966 tile+=8;
15033 39966 break;
15034
15035 case right:
15036 41960 tile+=12;
15037 41960 break;
15038 }
15039
15040 158716 tile+=f2;
15041 158716 }
15042 else
15043 {
15044
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12394 times.
✓ Branch 2 taken 7883 times.
✓ Branch 3 taken 8961 times.
✓ Branch 4 taken 12232 times.
41470 switch(misc&3)
15045 {
15046 case down:
15047 8961 flip=2;
15048
15049 [[fallthrough]];
15050 case up:
15051 21355 tile=(clk3)?188:189;
15052 21355 break;
15053
15054 case right:
15055 12232 flip=1;
15056 [[fallthrough]];
15057
15058 case left:
15059 20115 tile=(clk3)?186:187;
15060 20115 break;
15061 }
15062 }
15063
15064 200186 enemy::draw(dest);
15065 200186 }
15066
15067 168 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
15068 168 {
15069
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if ( !(editorflags & ENEMY_FLAG5) )
15070 {
15071
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 x = 120;
15072
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 y = 48;
15073 168 }
15074 else
15075 {
15076 if ( !(editorflags & ENEMY_FLAG6) )
15077 {
15078 x = X; y = Y;
15079 }
15080 else
15081 {
15082 x = X+8; y = Y;
15083 }
15084 }
15085 168 hzsz = 32; // can't be jumped.
15086 168 flameclk=0;
15087 168 misc=clk; // total head count
15088 168 clk3=clk; // live head count
15089 168 clk=0;
15090 168 clk2=60; // fire ball clock
15091 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
15092
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 hp=(guysbuf[id&0xFFF].attributes[1])*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
15093 168 dir = down;
15094 168 hxofs=4;
15095 168 hit_width=8;
15096 // frate=17*4;
15097 168 fading=fade_blue_poof;
15098 //nets+5420;
15099
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 35 times.
168 if(get_qr(qr_NEWENEMYTILES))
15100 {
15101 /*
15102 necktile=o_tile+8;
15103 if (dmisc3)
15104 {
15105 necktile+=8;
15106 }
15107 */
15108 133 necktile=o_tile+dmisc6;
15109 133 }
15110 else
15111 {
15112 35 necktile=s_tile;
15113 }
15114 168 }
15115
15116 155290 bool eGleeok::animate(int32_t index)
15117 {
15118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155290 times.
155290 if(switch_hooked) return enemy::animate(index);
15119
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 153091 times.
155290 if(dying)
15120 2199 return Dead(index);
15121
15122
2/2
✓ Branch 0 taken 152407 times.
✓ Branch 1 taken 684 times.
153091 if(clk==0)
15123 {
15124 684 removearmos(x,y,ffcactivated);
15125 684 }
15126
15127 // Check if a head was killed somehow...
15128
2/2
✓ Branch 0 taken 101719 times.
✓ Branch 1 taken 51372 times.
153091 if(index+1+clk3>=guys.Count())
15129 51372 clk3=guys.Count()-index-1;
15130
2/2
✓ Branch 0 taken 66050 times.
✓ Branch 1 taken 87041 times.
153091 if(index+1+misc>=guys.Count())
15131 87041 misc=guys.Count()-index-1;
15132
15133 //fix for the "kill all enemies" item
15134
2/2
✓ Branch 0 taken 153085 times.
✓ Branch 1 taken 6 times.
153091 if(hp==-1000)
15135 {
15136
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
15137 {
15138 // I haven't seen this fail, but it seems like it ought to be
15139 // possible, so I'm checking for it. - Saf
15140
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15141 break;
15142 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
15143 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
15144 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
15145 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
15146 12 }
15147
15148 6 clk3=0;
15149
15150
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
15151 {
15152
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15153 break;
15154 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15155 12 }
15156 6 }
15157
15158
2/2
✓ Branch 0 taken 403171 times.
✓ Branch 1 taken 153091 times.
556262 for(int32_t i=0; i<clk3; i++)
15159 {
15160 403171 enemy *head = ((enemy*)guys.spr(index+i+1));
15161 403171 head->dummy_int[1]=necktile;
15162 403171 head->parent_script_UID = this->script_UID;
15163
15164
2/2
✓ Branch 0 taken 320127 times.
✓ Branch 1 taken 83044 times.
403171 if(get_qr(qr_NEWENEMYTILES))
15165 {
15166 320127 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
15167 320127 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
15168 320127 }
15169 else
15170 {
15171 83044 head->dummy_int[2]=necktile+1; //connected head tile
15172 83044 head->dummy_int[3]=necktile+2; //flying head tile
15173 }
15174
15175 403171 head->dmisc5=dmisc5; //neck segments
15176
15177 /*
15178 if (dmisc3)
15179 {
15180 head->dummy_bool[0]=true;
15181 }
15182 */
15183
2/2
✓ Branch 0 taken 397516 times.
✓ Branch 1 taken 5655 times.
403171 if(head->hclk)
15184 {
15185
2/2
✓ Branch 0 taken 4427 times.
✓ Branch 1 taken 1228 times.
5655 if(hclk==0)
15186 {
15187 1228 hp -= 1000 - head->hp;
15188 1228 hclk = 33;
15189
15190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1228 times.
1228 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
15191
15192 1228 sfx(WAV_EHIT,pan(int32_t(head->x)));
15193 1228 }
15194
15195 5655 head->hclk = 0;
15196 5655 }
15197
15198 // Must be set in case of naughty ZScripts
15199 403171 head->hp = 1000;
15200 403171 }
15201
15202
2/2
✓ Branch 0 taken 152676 times.
✓ Branch 1 taken 415 times.
153091 if(hp<=(guysbuf[id&0xFFF].attributes[1]) * (clk3 - 1) * game->get_hero_dmgmult())
15203 {
15204 415 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
15205 415 hp=(guysbuf[id&0xFFF].attributes[1])*(--clk3)*game->get_hero_dmgmult();
15206 415 }
15207
15208
2/2
✓ Branch 0 taken 57409 times.
✓ Branch 1 taken 95682 times.
153091 if(!dmisc3)
15209 {
15210
4/4
✓ Branch 0 taken 5291 times.
✓ Branch 1 taken 90391 times.
✓ Branch 2 taken 1287 times.
✓ Branch 3 taken 4004 times.
95682 if(++clk2>72 && !(zc_oldrand()&3))
15211 {
15212 1287 int32_t i=zc_oldrand()%misc;
15213 1287 enemy *head = ((enemy*)guys.spr(index+i+1));
15214 1287 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
15215 1287 sfx(wpnsfx(wpn),pan(int32_t(x)));
15216 1287 clk2=0;
15217 1287 }
15218 95682 }
15219 else
15220 {
15221
4/4
✓ Branch 0 taken 2357 times.
✓ Branch 1 taken 55052 times.
✓ Branch 2 taken 1800 times.
✓ Branch 3 taken 557 times.
57409 if(++clk2>100 && !(zc_oldrand()&3))
15222 {
15223 557 enemy *head = ((enemy*)guys.spr(zc_oldrand()%misc+index+1));
15224 557 head->timer=zc_oldrand()%50+50;
15225 557 clk2=0;
15226 557 }
15227 }
15228
15229
3/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 152964 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
153091 if((hp<=0 && !immortal))
15230 {
15231
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 127 times.
517 for(int32_t i=0; i<misc; i++)
15232 390 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15233
15234
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 124 times.
127 if(flags&guy_never_return) never_return(index);
15235 127 }
15236
15237 153091 return enemy::animate(index);
15238 155290 }
15239
15240 1239 int32_t eGleeok::takehit(weapon*,weapon*)
15241 {
15242 1239 return 0;
15243 }
15244
15245 156918 void eGleeok::draw(BITMAP *dest)
15246 {
15247 156918 tile=o_tile;
15248
15249
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 154719 times.
156918 if(dying)
15250 {
15251 2199 enemy::draw(dest);
15252 2199 return;
15253 }
15254
15255 154719 int32_t f=clk/17;
15256
15257
2/2
✓ Branch 0 taken 120524 times.
✓ Branch 1 taken 34195 times.
154719 if(get_qr(qr_NEWENEMYTILES))
15258 {
15259 // body
15260 120524 xofs=-8;
15261 120524 yofs=32;
15262
15263
4/4
✓ Branch 0 taken 92588 times.
✓ Branch 1 taken 9155 times.
✓ Branch 2 taken 10095 times.
✓ Branch 3 taken 8686 times.
120524 switch(f)
15264
15265 {
15266 case 0:
15267 9155 tile+=0;
15268 9155 break;
15269
15270 case 1:
15271 10095 tile+=2;
15272 10095 break;
15273
15274 case 2:
15275 8686 tile+=4;
15276 8686 break;
15277
15278 default:
15279 92588 tile+=6;
15280 92588 break;
15281 }
15282 120524 }
15283 else
15284 {
15285 // body
15286 34195 xofs=-8;
15287 34195 yofs=32;
15288
15289
3/3
✓ Branch 0 taken 29222 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 2459 times.
34195 switch(f)
15290 {
15291 case 0:
15292 2514 tile+=0;
15293 2514 break;
15294
15295 case 2:
15296 2459 tile+=4;
15297 2459 break;
15298
15299 default:
15300 29222 tile+=2;
15301 29222 break;
15302 }
15303 }
15304
15305 154719 enemy::drawblock(dest,15);
15306 156918 }
15307
15308 156918 void eGleeok::draw2(BITMAP *dest)
15309 {
15310 // the neck stub
15311 156918 tile=necktile;
15312 156918 xofs=0;
15313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156918 times.
156918 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15314
15315
2/2
✓ Branch 0 taken 34737 times.
✓ Branch 1 taken 122181 times.
156918 if(get_qr(qr_NEWENEMYTILES))
15316 {
15317 122181 tile+=((clk&24)>>3);
15318 122181 }
15319
15320
3/4
✓ Branch 0 taken 154719 times.
✓ Branch 1 taken 2199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154719 times.
156918 if(hp > 0 && !dont_draw())
15321 {
15322
4/4
✓ Branch 0 taken 4731 times.
✓ Branch 1 taken 149988 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 3994 times.
154719 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15323 737 sprite::drawcloaked(dest);
15324 else
15325 153982 sprite::draw(dest);
15326 154719 }
15327 156918 }
15328
15329
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
1066 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
15330 533 {
15331
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 xoffset=0;
15332
2/4
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yoffset=(zfix)((dmisc5*4+2));
15333 // dummy_bool[0]=false;
15334 533 timer=0;
15335 /* fixing */
15336 533 hp=1000;
15337
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 step=1;
15338 533 item_set=0;
15339 //x=120; y=70;
15340
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 x = xoffset+parent->x;
15341
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 y = yoffset+parent->y;
15342 533 hxofs=4;
15343 533 hit_width=8;
15344
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 533 times.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15345 533 clk2=clk; // how int32_t to wait before moving first time
15346 533 clk=0;
15347 533 mainguy=count_enemy=false;
15348
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dir=zc_oldrand();
15349 533 clk3=((dir&2)>>1)+2; // left or right
15350 533 dir&=1; // up or down
15351
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dmisc5=vbound(dmisc5,1,255);
15352 533 isCore = false;
15353
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 parentCore = parent->getUID();
15354
2/2
✓ Branch 0 taken 2132 times.
✓ Branch 1 taken 533 times.
2665 for(int32_t i=0; i<dmisc5; i++)
15355 {
15356 2132 nxoffset[i] = 0;
15357 2132 nyoffset[i] = 0;
15358
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
15359
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
15360 2132 }
15361
15362 533 necktile=0;
15363 //TODO compatibility? -DD
15364 /*
15365 for(int32_t i=0; i<4; i++)
15366 {
15367 nx[i]=124;
15368 ny[i]=i*6+48;
15369 }*/
15370 533 bgsfx=-1;
15371 //no need for deadsfx
15372 533 }
15373
15374 515535 bool esGleeok::animate(int32_t index)
15375 {
15376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515535 times.
515535 if(switch_hooked) return enemy::animate(index);
15377 // don't call removearmos() - it's a segment.
15378
15379 515535 dmisc5=vbound(dmisc5,1,255);
15380
15381
2/2
✓ Branch 0 taken 112773 times.
✓ Branch 1 taken 402762 times.
515535 if(misc == 0)
15382 {
15383 402762 x = (xoffset+parent->x);
15384 402762 y = (yoffset+parent->y);
15385
15386
2/2
✓ Branch 0 taken 1611048 times.
✓ Branch 1 taken 402762 times.
2013810 for(int32_t i=0; i<dmisc5; i++)
15387 {
15388 1611048 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15389 1611048 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15390 1611048 }
15391 402762 }
15392
15393 // set up the head tiles
15394 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15395 /*
15396 if (dummy_bool[0]) //if this is a flame gleeok
15397 {
15398 headtile+=180;
15399 }
15400 */
15401 515535 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15402 515535 flyingheadtile=dummy_int[3];
15403
15404 // set up the neck tiles
15405 515535 necktile=dummy_int[1];
15406
15407
2/2
✓ Branch 0 taken 112702 times.
✓ Branch 1 taken 402833 times.
515535 if(get_qr(qr_NEWENEMYTILES))
15408 {
15409 402833 necktile+=((clk&24)>>3);
15410 402833 }
15411
15412 /*
15413 else
15414 {
15415 necktile=145;
15416 }
15417 */
15418 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15419
15420
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 402762 times.
✓ Branch 2 taken 112071 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 402 times.
515535 switch(misc)
15421 {
15422 case 0: // live head
15423 // set up the attached head tiles
15424 402762 tile=headtile;
15425
15426
2/2
✓ Branch 0 taken 82942 times.
✓ Branch 1 taken 319820 times.
402762 if(get_qr(qr_NEWENEMYTILES))
15427 {
15428 319820 tile+=((clk&24)>>3);
15429 /*
15430 if (dummy_bool[0]) {
15431 tile+=1561;
15432 }
15433 */
15434 319820 }
15435
15436 /*
15437 else
15438 {
15439 tile=146;
15440 }
15441 */
15442
4/4
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 298314 times.
✓ Branch 2 taken 11616 times.
✓ Branch 3 taken 92832 times.
402762 if(++clk2>=0 && !(clk2&3))
15443 {
15444
2/2
✓ Branch 0 taken 90773 times.
✓ Branch 1 taken 2059 times.
92832 if(y<= (int32_t)parent->y + 8) dir=down;
15445
15446
2/2
✓ Branch 0 taken 90911 times.
✓ Branch 1 taken 1921 times.
92832 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15447
15448
4/4
✓ Branch 0 taken 9757 times.
✓ Branch 1 taken 83075 times.
✓ Branch 2 taken 9465 times.
✓ Branch 3 taken 292 times.
92832 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15449 {
15450 292 dir^=1;
15451 292 }
15452
15453 92832 zfix tempx = x;
15454 92832 zfix tempy = y;
15455
15456 92832 sprite::move(step);
15457 92832 xoffset += (x-tempx);
15458 92832 yoffset += (y-tempy);
15459
15460
2/2
✓ Branch 0 taken 3863 times.
✓ Branch 1 taken 88969 times.
92832 if(clk2>=4)
15461 {
15462 3863 clk3^=1;
15463 3863 clk2=-4;
15464 3863 }
15465 else
15466 {
15467
2/2
✓ Branch 0 taken 87991 times.
✓ Branch 1 taken 978 times.
88969 if(x <= (int32_t)parent->x-(dmisc5*6))
15468 {
15469 978 clk3=right;
15470 978 }
15471
15472
2/2
✓ Branch 0 taken 88008 times.
✓ Branch 1 taken 961 times.
88969 if(x >= (int32_t)parent->x+(dmisc5*6))
15473 {
15474 961 clk3=left;
15475 961 }
15476
15477
4/4
✓ Branch 0 taken 60029 times.
✓ Branch 1 taken 28940 times.
✓ Branch 2 taken 56316 times.
✓ Branch 3 taken 3713 times.
88969 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15478 {
15479 3713 clk3^=1; // x jig
15480 3713 }
15481 else
15482 {
15483
4/4
✓ Branch 0 taken 29223 times.
✓ Branch 1 taken 56033 times.
✓ Branch 2 taken 28372 times.
✓ Branch 3 taken 851 times.
85256 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15484 {
15485 851 clk3^=1; // x switch back
15486 851 }
15487
15488 85256 clk2=-4;
15489 }
15490 }
15491
15492 92832 zc_swap(dir,clk3);
15493 92832 tempx = x;
15494 92832 tempy = y;
15495 92832 sprite::move(step);
15496 92832 xoffset += (x-tempx);
15497 92832 yoffset += (y-tempy);
15498 92832 zc_swap(dir,clk3);
15499
15500
2/2
✓ Branch 0 taken 278496 times.
✓ Branch 1 taken 92832 times.
371328 for(int32_t i=1; i<dmisc5; i++)
15501 {
15502 278496 nxoffset[i] = (zc_oldrand()%3);
15503 278496 nyoffset[i] = (zc_oldrand()%3);
15504 278496 }
15505 92832 }
15506
15507 402762 break;
15508
15509 case 1: // flying head
15510
2/2
✓ Branch 0 taken 6589 times.
✓ Branch 1 taken 105482 times.
112071 if(clk>=0)
15511
15512 {
15513 105482 variable_walk_8(rate,homing,hrate,spw_floater);
15514 105482 }
15515
15516 112071 break;
15517
15518 // the following are messages sent from the main guy...
15519 case -1: // got chopped off
15520 {
15521 300 misc=1;
15522 300 superman=1;
15523 300 hxofs=xofs=0;
15524 300 hit_width=16;
15525 300 cs=8;
15526 300 clk=-24;
15527 300 clk2=40;
15528 300 dir=(zc_oldrand()&7)+8;
15529 300 step=8.0/9.0;
15530 }
15531 300 break;
15532
15533 case -2: // the big guy is dead
15534 402 return true;
15535 }
15536
15537
2/2
✓ Branch 0 taken 475008 times.
✓ Branch 1 taken 40125 times.
515133 if(timer)
15538 {
15539
2/2
✓ Branch 0 taken 35334 times.
✓ Branch 1 taken 4791 times.
40125 if(!(timer%8))
15540 {
15541 4791 FireBreath(true);
15542 4791 }
15543
15544 40125 --timer;
15545 40125 }
15546
15547 515133 return enemy::animate(index);
15548 515535 }
15549
15550 7080 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
15551 {
15552
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7080 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7080 if ((editorflags & ENEMY_FLAG7) && misc == 1)
15553 {
15554 int32_t wpnId = w->id;
15555
15556 if(dying)
15557 return 0;
15558
15559 switch(wpnId)
15560 {
15561 case wLitBomb:
15562 case wLitSBomb:
15563 case wBait:
15564 case wWhistle:
15565 case wFire:
15566 case wWind:
15567 case wSSparkle:
15568 case wFSparkle:
15569 case wPhantom:
15570 return 0;
15571
15572 case wHookshot:
15573 case wBrang:
15574 case wBeam:
15575 case wArrow:
15576 case wMagic:
15577 case wBomb:
15578 case wSBomb:
15579 sfx(WAV_CHINK,pan(int32_t(x)));
15580 break;
15581 default:
15582 break;
15583 }
15584
15585 return 1;
15586 }
15587 else
15588 {
15589 7080 int32_t ret = enemy::takehit(w,realweap);
15590
15591
2/2
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 5655 times.
7080 if(ret==-1)
15592 5655 return 2; // force it to wait a frame before checking sword attacks again
15593
15594 1425 return ret;
15595 }
15596 7080 }
15597
15598 521456 void esGleeok::draw(BITMAP *dest)
15599 {
15600 521456 dmisc5=vbound(dmisc5,1,255);
15601
15602
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 409106 times.
✓ Branch 2 taken 112350 times.
521456 switch(misc)
15603 {
15604 case 0: //neck
15605
1/2
✓ Branch 0 taken 409106 times.
✗ Branch 1 not taken.
409106 if(!dont_draw())
15606 {
15607
2/2
✓ Branch 0 taken 1227318 times.
✓ Branch 1 taken 409106 times.
1636424 for(int32_t i=1; i<dmisc5; i++) //draw the neck
15608 {
15609
2/2
✓ Branch 0 taken 978198 times.
✓ Branch 1 taken 249120 times.
1227318 if(get_qr(qr_NEWENEMYTILES))
15610 {
15611
4/4
✓ Branch 0 taken 23100 times.
✓ Branch 1 taken 955098 times.
✓ Branch 2 taken 20889 times.
✓ Branch 3 taken 2211 times.
978198 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15612 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,0);
15613 else
15614 975987 overtile16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,cs,0);
15615 978198 }
15616 else
15617 {
15618
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 244842 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
249120 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15619 overtilecloaked16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,0);
15620 else
15621 249120 overtile16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,cs,0);
15622 }
15623 1227318 }
15624 409106 }
15625
15626 409106 break;
15627
15628 case 1: //flying head
15629 112350 tile=flyingheadtile;
15630
15631
2/2
✓ Branch 0 taken 82692 times.
✓ Branch 1 taken 29658 times.
112350 if(get_qr(qr_NEWENEMYTILES))
15632 {
15633 82692 tile+=((clk&24)>>3);
15634 82692 break;
15635 }
15636
15637 /*
15638 else
15639 {
15640 tile=(clk&1)?147:148;
15641 break;
15642 }
15643 */
15644 29658 }
15645 521456 }
15646
15647 521456 void esGleeok::draw2(BITMAP *dest)
15648 {
15649 521456 enemy::draw(dest);
15650 521456 }
15651
15652 190 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
15653 190 {
15654
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ( !(editorflags & ENEMY_FLAG5) )
15655 {
15656
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 x = 128;
15657
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 y = 48;
15658 190 }
15659 else { x = X; y = Y; }
15660 190 adjusted=false;
15661
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 dir=(zc_oldrand()&7)+8;
15662 //step=0.25;
15663 190 flycnt=dmisc1;
15664 190 flycnt2=dmisc2;
15665 190 loopcnt=0;
15666 190 clk4 = 0;
15667 190 clk5 = 0;
15668 190 clk6 = 0;
15669 190 clk7 = 0;
15670
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
15671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc29 == 0)
15672 {
15673
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15674 {
15675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc29 = (90 / 3);
15676 105 else dmisc29 = (84 / 3);
15677 105 }
15678 else
15679 {
15680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc29 = (90 / 2);
15681 85 else dmisc29 = (84 / 2);
15682 }
15683 190 }
15684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc30 == 0)
15685 {
15686
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15687 {
15688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc30 = (90 / 3)*0.5;
15689 105 else dmisc30 = (84 / 3)*0.5;
15690 105 }
15691 else
15692 {
15693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc30 = (90 / 2)*0.5;
15694 85 else dmisc30 = (84 / 2)*0.5;
15695 }
15696 190 }
15697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc31 == 0)
15698 {
15699
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15700 {
15701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc31 = (90 / 3)*2;
15702 105 else dmisc31 = (84 / 3)*2;
15703 105 }
15704 else
15705 {
15706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc31 = (90 / 2)*0.5;
15707 85 else dmisc31 = (84 / 2)*0.5;
15708 }
15709 190 }
15710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc32 == 0)
15711 {
15712
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15713 {
15714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc32 = (90 / 3);
15715 105 else dmisc32 = (84 / 3);
15716 105 }
15717 else
15718 {
15719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc32 = (90 / 2)*0.25;
15720 85 else dmisc32 = (84 / 2)*0.25;
15721 }
15722 190 }
15723
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 init_size_flags();
15724 190 }
15725
15726 161885 bool ePatra::animate(int32_t index)
15727 {
15728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161885 times.
161885 if(switch_hooked) return enemy::animate(index);
15729
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 160441 times.
161885 if(dying)
15730 {
15731
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1444 times.
1516 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
15732 {
15733 72 ((enemy*)guys.spr(i))->hp = -1000;
15734 72 }
15735
15736 1444 return Dead(index);
15737 }
15738
15739 160441 double basesize = 84;
15740
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc10) basesize = 90;
15741 160441 double halfsize = basesize / 2;
15742 160441 double quartersize = halfsize / 2;
15743 160441 double twothirdsize = (basesize / 3)*2;
15744 160441 double onethirdsize = (basesize / 3);
15745
15746
15747
2/2
✓ Branch 0 taken 123507 times.
✓ Branch 1 taken 36934 times.
160441 if(clk==0)
15748 {
15749 36934 removearmos(x,y,ffcactivated);
15750 36934 }
15751
15752
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160441 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160441 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
15753 {
15754
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
160441 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
15755
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (loopcnt < 0) ++clk2;
15756
2/2
✓ Branch 0 taken 158644 times.
✓ Branch 1 taken 1797 times.
160441 if(++clk2>basesize)
15757 {
15758 1797 clk2=0;
15759
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1797 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1797 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
15760 {
15761
2/2
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 865 times.
1797 if(loopcnt > 0)
15762 932 --loopcnt;
15763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 else if (loopcnt == 0)
15764 {
15765
2/2
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 356 times.
865 if((misc%dmisc6)==0)
15766 {
15767
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 if (dmisc21 > 0) loopcnt=-dmisc21;
15768 356 else loopcnt=dmisc7;
15769 356 }
15770 865 }
15771 else if (loopcnt == -1) loopcnt=dmisc7;
15772 else ++loopcnt;
15773
15774
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1797 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
15775 1797 }
15776 else
15777 {
15778 loopcnt = 0;
15779 misc = 1;
15780 }
15781 1797 }
15782 160441 }
15783
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk4 > 0) --clk4;
15784
15785
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 < 0)
15786 {
15787 if (dmisc5 == 1 || dmisc5 == 3)
15788 {
15789 if (get_qr(qr_NEWENEMYTILES))
15790 {
15791 if (clk7 <= 0 || clk6 != -16) ++clk6;
15792 if (clk6 == 0) o_tile=d->e_tile;
15793 else
15794 {
15795 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
15796 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
15797 }
15798 }
15799 else clk6 = 0;
15800 }
15801 }
15802
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk6;
15803
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk5 < 0) ++clk5;
15804
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk5;
15805
15806
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160441 if (clk7 > 0 && clk6 >= -16) --clk7;
15807
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 > 0) clk7 = 0;
15808
15809
2/2
✓ Branch 0 taken 660384 times.
✓ Branch 1 taken 160441 times.
820825 for(int32_t i=index+1; i<index+flycnt+1; i++)
15810 {
15811 //outside ring
15812
2/2
✓ Branch 0 taken 659040 times.
✓ Branch 1 taken 1344 times.
660384 if(!adjusted)
15813 {
15814
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 192 times.
1344 if(get_qr(qr_NEWENEMYTILES))
15815 {
15816 1152 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
15817 1152 enemy *s = ((enemy*)guys.spr(i));
15818 1152 s->parent_script_UID = this->script_UID;
15819 1152 }
15820 else
15821 {
15822 192 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15823 192 enemy *s = ((enemy*)guys.spr(i));
15824 192 s->parent_script_UID = this->script_UID;
15825 }
15826
15827 1344 ((enemy*)guys.spr(i))->cs=dmisc9;
15828 1344 ((enemy*)guys.spr(i))->hp=dmisc3;
15829 1344 }
15830
15831
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 659620 times.
660384 if(((enemy*)guys.spr(i))->hp <= 0)
15832 {
15833
2/2
✓ Branch 0 taken 2889 times.
✓ Branch 1 taken 764 times.
3653 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15834 {
15835 2889 guys.swap(j,j+1);
15836 2889 }
15837
15838
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 670 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
764 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
15839 764 }
15840 else
15841 {
15842 659620 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15843
1/2
✓ Branch 0 taken 659620 times.
✗ Branch 1 not taken.
659620 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
15844
15845
2/2
✓ Branch 0 taken 212037 times.
✓ Branch 1 taken 447583 times.
659620 if(!dmisc4) //Big Ring
15846 {
15847 //maybe playing_field_offset here?
15848
2/2
✓ Branch 0 taken 237330 times.
✓ Branch 1 taken 210253 times.
447583 if(loopcnt>0)
15849 {
15850
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15851
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15852 237330 }
15853 else
15854 {
15855 210253 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15856 210253 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15857 }
15858
15859 447583 temp_x=guys.spr(i)->x;
15860 447583 temp_y=guys.spr(i)->y;
15861 447583 }
15862 else //Oval
15863 {
15864 212037 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15865 212037 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15866
15867
2/2
✓ Branch 0 taken 121041 times.
✓ Branch 1 taken 90996 times.
212037 if(loopcnt>0)
15868 {
15869 121041 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15870
1/2
✓ Branch 0 taken 121041 times.
✗ Branch 1 not taken.
121041 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
15871 121041 }
15872 else
15873 {
15874 90996 guys.spr(i)->x = circle_x;
15875 90996 guys.spr(i)->y = circle_y;
15876 }
15877
15878 212037 temp_x=circle_x;
15879 212037 temp_y=circle_y;
15880 }
15881
15882 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15883 659620 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15884
15885
4/4
✓ Branch 0 taken 124008 times.
✓ Branch 1 taken 535612 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83117 times.
659620 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15886 {
15887 83117 guys.spr(i)->dir=l_down;
15888 83117 }
15889
4/4
✓ Branch 0 taken 124459 times.
✓ Branch 1 taken 452044 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83568 times.
576503 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15890 {
15891 83568 guys.spr(i)->dir=left;
15892 83568 }
15893
4/4
✓ Branch 0 taken 123345 times.
✓ Branch 1 taken 369590 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82454 times.
492935 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15894 {
15895 82454 guys.spr(i)->dir=l_up;
15896 82454 }
15897
4/4
✓ Branch 0 taken 123079 times.
✓ Branch 1 taken 287402 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82188 times.
410481 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15898 {
15899 82188 guys.spr(i)->dir=up;
15900 82188 }
15901
4/4
✓ Branch 0 taken 122491 times.
✓ Branch 1 taken 205802 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81600 times.
328293 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15902 {
15903 81600 guys.spr(i)->dir=r_up;
15904 81600 }
15905
4/4
✓ Branch 0 taken 122884 times.
✓ Branch 1 taken 123809 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81993 times.
246693 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15906 {
15907 81993 guys.spr(i)->dir=right;
15908 81993 }
15909
4/4
✓ Branch 0 taken 122590 times.
✓ Branch 1 taken 42110 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81699 times.
164700 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15910 {
15911 81699 guys.spr(i)->dir=r_down;
15912 81699 }
15913 else
15914 {
15915 83001 guys.spr(i)->dir=down;
15916 }
15917
15918 659620 guys.spr(i)->x += x;
15919 659620 guys.spr(i)->y += y;
15920 }
15921 660384 }
15922
15923
7/22
✓ Branch 0 taken 106957 times.
✓ Branch 1 taken 53484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106957 times.
✓ Branch 4 taken 21153 times.
✓ Branch 5 taken 32331 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 21153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 32331 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
160441 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
15924 {
15925 32331 int timeneeded = 48;
15926 32331 int patbreath = (zc_oldrand()%50+50);
15927
2/2
✓ Branch 0 taken 24549 times.
✓ Branch 1 taken 7782 times.
32331 if ((patbreath % 4) == 0) ++patbreath;
15928
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratBREATH)
15929 {
15930 timeneeded = 48 + patbreath;
15931 }
15932
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratSTREAM)
15933 {
15934 timeneeded = 48 + 96;
15935 }
15936
4/14
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32331 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 249 times.
✓ Branch 11 taken 249 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
32331 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
15937
2/2
✓ Branch 0 taken 32331 times.
✓ Branch 1 taken 249 times.
32580 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
15938
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 32082 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
32580 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15939 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
15940 249 && (clk6 >= 0) //if not in the middle of firing...
15941 249 && clk6 >= dmisc19) //if over the set cooldown between shots...
15942
2/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
249 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
15943 {
15944
1/3
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
249 switch(dmisc28)
15945 {
15946 case patratSTREAM:
15947 {
15948 clk7 = 97;
15949 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15950 else clk6 = 0;
15951 break;
15952 }
15953 case patratBREATH:
15954 {
15955 clk7 = patbreath;
15956 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15957 else clk6 = 0;
15958 break;
15959 }
15960 default:
15961 {
15962
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15963 {
15964 clk6 = -48;
15965 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15966 }
15967 else
15968 {
15969 249 clk6 = 0;
15970
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15971 249 FirePatraWeapon();
15972 }
15973 249 break;
15974 }
15975 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15976 249 }
15977
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (clk6 < 0)
15978 {
15979 switch(dmisc28)
15980 {
15981 case patratSTREAM:
15982 {
15983 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
15984 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15985 break;
15986 }
15987 case patratBREATH:
15988 {
15989 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
15990 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15991 break;
15992 }
15993 default:
15994 {
15995 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
15996 {
15997 FirePatraWeapon();
15998 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15999 }
16000 break;
16001 }
16002 }
16003 }
16004 32331 }
16005
16006 160441 int randattempts = 0;
16007 160441 int randeye = 0;
16008
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if (flycnt2 > 0)
16009 {
16010 46240 do
16011 {
16012
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✓ Branch 2 taken 44221 times.
✓ Branch 3 taken 2019 times.
46240 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
16013 46240 randeye += (index + flycnt + 1);
16014 46240 ++randattempts;
16015
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46240 times.
46240 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
16016 46240 }
16017 160441 bool dofire = false;
16018
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc20)
16019 {
16020 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
16021 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
16022 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
16023 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
16024 || ((((((misc%dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
16025 {
16026 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16027 {
16028 if (clk5 >= dmisc19)
16029 {
16030 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
16031 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
16032 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + 96)) ||
16033 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48)))
16034 || dmisc18 == -1)
16035 dofire = true;
16036 }
16037 }
16038 }
16039 }
16040
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if(flycnt2)
16041 {
16042
2/2
✓ Branch 0 taken 334429 times.
✓ Branch 1 taken 46240 times.
380669 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
16043 {
16044
2/2
✓ Branch 0 taken 334117 times.
✓ Branch 1 taken 312 times.
334429 if(!adjusted)
16045 {
16046 312 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
16047
16048
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(get_qr(qr_NEWENEMYTILES))
16049 {
16050
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16051 {
16052
2/3
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
312 switch(dmisc5)
16053 {
16054 // Center eye shoots projectiles; make room for its firing tiles
16055 case 1:
16056 case 3:
16057 144 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
16058 144 break;
16059
16060 // Center eyes does not shoot; use tiles two rows below for inner eyes.
16061 default:
16062 case 2:
16063 168 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
16064 168 break;
16065 }
16066 312 }
16067 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
16068 312 }
16069 else
16070 {
16071 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16072 }
16073
16074 312 ((enemy*)guys.spr(i))->cs=dmisc9;
16075
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
16076 312 }
16077
16078
2/2
✓ Branch 0 taken 263816 times.
✓ Branch 1 taken 70613 times.
334429 if(flycnt>0)
16079 {
16080 263816 ((enemy*)guys.spr(i))->superman=true;
16081 263816 }
16082 else
16083 {
16084 70613 ((enemy*)guys.spr(i))->superman=false;
16085 }
16086
16087
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 334284 times.
334429 if(((enemy*)guys.spr(i))->hp <= 0)
16088 {
16089
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 145 times.
414 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16090 {
16091 269 guys.swap(j,j+1);
16092 269 }
16093
16094
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
145 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
16095 145 }
16096 else
16097 {
16098 334284 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16099
1/2
✓ Branch 0 taken 334284 times.
✗ Branch 1 not taken.
334284 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
16100
16101
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 327025 times.
334284 if(dmisc4==0)
16102 {
16103
2/2
✓ Branch 0 taken 168378 times.
✓ Branch 1 taken 158647 times.
327025 if(loopcnt>0)
16104 {
16105
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16106
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16107 168378 }
16108 else
16109 {
16110 158647 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16111 158647 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16112 }
16113
16114 327025 temp_x=guys.spr(i)->x;
16115 327025 temp_y=guys.spr(i)->y;
16116 327025 }
16117 else
16118 {
16119 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16120 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16121
16122
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
16123 {
16124 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16125
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
16126 3965 }
16127 else
16128 {
16129 3294 guys.spr(i)->x = circle_x;
16130 3294 guys.spr(i)->y = circle_y;
16131 }
16132
16133 7259 temp_x=circle_x;
16134 7259 temp_y=circle_y;
16135 }
16136
16137 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16138 334284 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16139
16140
4/4
✓ Branch 0 taken 61619 times.
✓ Branch 1 taken 272665 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41746 times.
334284 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16141 {
16142 41746 guys.spr(i)->dir=l_down;
16143 41746 }
16144
4/4
✓ Branch 0 taken 61607 times.
✓ Branch 1 taken 230931 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41734 times.
292538 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16145 {
16146 41734 guys.spr(i)->dir=left;
16147 41734 }
16148
4/4
✓ Branch 0 taken 61615 times.
✓ Branch 1 taken 189189 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41742 times.
250804 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16149 {
16150 41742 guys.spr(i)->dir=l_up;
16151 41742 }
16152
4/4
✓ Branch 0 taken 61631 times.
✓ Branch 1 taken 147431 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41758 times.
209062 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16153 {
16154 41758 guys.spr(i)->dir=up;
16155 41758 }
16156
4/4
✓ Branch 0 taken 61703 times.
✓ Branch 1 taken 105601 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41830 times.
167304 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16157 {
16158 41830 guys.spr(i)->dir=r_up;
16159 41830 }
16160
4/4
✓ Branch 0 taken 61697 times.
✓ Branch 1 taken 63777 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41824 times.
125474 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16161 {
16162 41824 guys.spr(i)->dir=right;
16163 41824 }
16164
4/4
✓ Branch 0 taken 61725 times.
✓ Branch 1 taken 21925 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41852 times.
83650 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16165 {
16166 41852 guys.spr(i)->dir=r_down;
16167 41852 }
16168 else
16169 {
16170 41798 guys.spr(i)->dir=down;
16171 }
16172
16173 334284 guys.spr(i)->x += x;
16174 334284 guys.spr(i)->y = y-guys.spr(i)->y;
16175
16176
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 334284 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 189016 times.
✓ Branch 5 taken 145268 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 189016 times.
334284 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
16177 {
16178 /*
16179 if(!(zc_oldrand()&127))
16180 {
16181 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
16182 sfx(wpnsfx(wpn),pan(int32_t(x)));
16183 }
16184 */
16185
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
145268 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
16186 {
16187 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
16188 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16189 {
16190 if (dmisc5 == 3)
16191 {
16192 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16193 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
16194 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
16195 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16196 }
16197 else
16198 {
16199 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16200 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16201 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
16202 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16203 }
16204 }
16205 else
16206 {
16207 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16208 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
16209 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
16210 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16211 }
16212 }
16213
4/6
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145268 times.
✓ Branch 4 taken 145268 times.
✓ Branch 5 taken 145268 times.
145268 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
16214
1/2
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
145268 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
16215
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
16216 {
16217
1/5
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
145268 switch(dmisc20) //Patra Attack Patterns
16218 {
16219 case 4: //Single one rapidfires
16220 {
16221 if (dofire && i == randeye)
16222 {
16223 ((esPatra*)guys.spr(i))->clk5 = -16;
16224 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
16225 ((esPatra*)guys.spr(i))->clk4 = 96;
16226 clk5 = -3;
16227 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16228 }
16229 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
16230 {
16231 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16232 sfx(wpnsfx(wpn),pan(int32_t(x)));
16233 }
16234 break;
16235 }
16236 case 3: //Ring
16237 {
16238 if (dofire)
16239 {
16240 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16241 {
16242 ((esPatra*)guys.spr(i))->clk5 = -48;
16243 clk5 = -48;
16244 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16245 }
16246 else
16247 {
16248 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16250 int32_t m=Ewpns.Count()-1;
16251 weapon *ew = (weapon*)(Ewpns.spr(m));
16252
16253 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16254 ((esPatra*)guys.spr(i))->clk5 = 0;
16255 clk5 = 0;
16256 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16257 }
16258 }
16259 if (((esPatra*)guys.spr(i))->clk5 == -16)
16260 {
16261 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16262 sfx(wpnsfx(wpn),pan(int32_t(x)));
16263 int32_t m=Ewpns.Count()-1;
16264 weapon *ew = (weapon*)(Ewpns.spr(m));
16265
16266 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16267 }
16268 break;
16269 }
16270 case 2: //one after another
16271 {
16272 if (dofire)
16273 {
16274 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
16275 clk5 = -48 - (12*flycnt2);
16276 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16277 }
16278 if (((esPatra*)guys.spr(i))->clk5 == -16)
16279 {
16280 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16281 sfx(wpnsfx(wpn),pan(int32_t(x)));
16282 }
16283 break;
16284 }
16285 case 1: //random one eye
16286 {
16287 if (dofire && i == randeye)
16288 {
16289 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16290 {
16291 ((esPatra*)guys.spr(i))->clk5 = -48;
16292 clk5 = -48;
16293 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16294 }
16295 else
16296 {
16297 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16298 sfx(wpnsfx(wpn),pan(int32_t(x)));
16299 ((esPatra*)guys.spr(i))->clk5 = 0;
16300 clk5 = 0;
16301 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16302 }
16303 }
16304 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16305 {
16306 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16307 sfx(wpnsfx(wpn),pan(int32_t(x)));
16308 }
16309 break;
16310 }
16311 default: //old behavior, all eyes can fire any time
16312 {
16313
3/8
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1155 times.
✓ Branch 5 taken 1155 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
16314
3/6
✓ Branch 0 taken 145268 times.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1155 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16315
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
16316 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48))))
16317 {
16318
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16319 {
16320 ((esPatra*)guys.spr(i))->clk5 = -48;
16321 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16322 }
16323 else
16324 {
16325 1155 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16326 1155 sfx(wpnsfx(wpn),pan(int32_t(x)));
16327 1155 ((esPatra*)guys.spr(i))->clk5 = 0;
16328
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16329 }
16330 1155 }
16331
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16332 {
16333 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16334 sfx(wpnsfx(wpn),pan(int32_t(x)));
16335 }
16336 145268 break;
16337 }
16338 }
16339 145268 }
16340 145268 }
16341
16342 }
16343 334429 }
16344 46240 }
16345
16346 160441 adjusted=true;
16347 160441 return enemy::animate(index);
16348 161885 }
16349
16350 249 void ePatra::FirePatraWeapon()
16351 { //.707
16352 249 int32_t xoff = 0;
16353 249 int32_t yoff = 0;
16354
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_WIDTH)
16355 {
16356 xoff += hxofs;
16357 if (weapoverrideFLAGS & OVERRIDE_HIT_WIDTH)
16358 xoff += (hit_width / 2) - (weap_tilew * 8);
16359 else
16360 xoff += (hit_width / 2) - 8;
16361 }
16362
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
16363 {
16364 yoff += hyofs;
16365 if (weapoverrideFLAGS & OVERRIDE_HIT_HEIGHT)
16366 yoff += (hit_height / 2) - (weap_tileh * 8);
16367 else
16368 yoff += (hit_height / 2) - 8;
16369 }
16370 249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16371
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
249 switch (dmisc28)
16372 {
16373 case patrat8SHOT: //Fire Wizzrobe
16374 case patrat4SHOTDIAG:
16375 case patrat4SHOTRAND:
16376 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
16377 {
16378 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
16379 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16380 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16381 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16382
16383 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
16384 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16385 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16386 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16387
16388 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16389 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16390 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16391 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16392
16393 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16394 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16395 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16396 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16397
16398 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16399 }
16400
16401 [[fallthrough]];
16402 case patrat4SHOTCARD: //Stalfos 3
16403 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16404 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16405 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16406 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16407 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16408 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16409 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16410 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16411 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16412 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16413 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16414 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16415 break;
16416
16417 default:
16418 249 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16419
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16420 249 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16421
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 249 times.
249 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16422
4/8
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 249 times.
249 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16423 {
16424 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16425 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16426 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16427 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16428 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16429 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16430 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16431 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16432 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16433 {
16434 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16435 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16436 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16437 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16438 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16439 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16440 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16441 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16442 }
16443 }
16444 249 break;
16445
16446 }
16447 249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16448 //+0.46364761
16449 //11.80
16450 249 }
16451
16452 324242 void ePatra::draw(BITMAP *dest)
16453 {
16454 324242 tile=o_tile;
16455 324242 update_enemy_frame();
16456 324242 enemy::draw(dest);
16457 324242 }
16458
16459 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16460 {
16461 int32_t ret = enemy::defend(wpnId, power, edef);
16462
16463 if(ret < 0 && (flycnt||flycnt2))
16464 return 0;
16465
16466 return ret;
16467 }
16468
16469 1733 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16470 {
16471 1733 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16472
16473
6/6
✓ Branch 0 taken 1613 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 834 times.
✓ Branch 4 taken 447 times.
✓ Branch 5 taken 332 times.
1733 if(ret < 0 && (flycnt||flycnt2))
16474 1281 return 0;
16475
16476 452 return ret;
16477 1733 }
16478
16479 190 void ePatra::init_size_flags() {
16480 190 SIZEflags = d->SIZEflags;
16481
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16482
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16483 // al_trace("Enemy txsz:%i\n", txsz);
16484
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = tysz; if (tysz > 1) extend = 3; }
16485
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16486
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = hit_width;
16487
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hit_width = 32;
16488
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = hit_height;
16489
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = hzsz;
16490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = hxofs;
16491
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hxofs = -8;
16492
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = hyofs;
16493 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)xofs;
16495
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) xofs = -8;
16496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16497 {
16498 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16499 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16500 }
16501
1/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset) - 8;
16502
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (editorflags & ENEMY_FLAG8) misc = 1;
16503
16504
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)zofs;
16505
16506 190 }
16507
16508 3312 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
16509 1656 {
16510 //cs=8;
16511 1656 item_set=0;
16512 1656 misc=clk;
16513 1656 clk4 = 0;
16514 1656 clk5 = 0;
16515 1656 clk = -((misc*21)>>1)-1;
16516
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16517 1656 hit_width=12;
16518 1656 hit_height=12;
16519 1656 hxofs=2;
16520 1656 hyofs=2;
16521 1656 extend = 0;
16522 1656 txsz = 1;
16523 1656 tysz = 1;
16524 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16525 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16526 int32_t prntSIZEflags = prntenemy->SIZEflags;
16527 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16528 // al_trace("Enemy txsz:%i\n", txsz);
16529 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16530 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16531 else
16532 hxsz=12;
16533 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16534 else
16535 hysz=12;
16536 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16537 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16538 else
16539 hxofs=2;
16540 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16541 else hyofs=2;
16542 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16543 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16544 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16545 {
16546 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16547 }
16548
16549 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
16550 */
16551 1656 mainguy=count_enemy=false;
16552 1656 bgsfx=-1;
16553 //o_tile=0;
16554
2/4
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 flags &= (~guy_never_return);
16555 1656 deadsfx = WAV_EDEAD;
16556 1656 hitsfx = WAV_EHIT;
16557 1656 isCore = false;
16558 1656 }
16559
16560 1010584 bool esPatra::animate(int32_t index)
16561 {
16562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1010584 times.
1010584 if(switch_hooked) return enemy::animate(index);
16563
2/2
✓ Branch 0 taken 15160 times.
✓ Branch 1 taken 995424 times.
1010584 if(dying)
16564 15160 return Dead(index);
16565
16566 995424 return enemy::animate(index);
16567 1010584 }
16568
16569 2028196 void esPatra::draw(BITMAP *dest)
16570 {
16571
2/2
✓ Branch 0 taken 1721294 times.
✓ Branch 1 taken 306902 times.
2028196 if(get_qr(qr_NEWENEMYTILES))
16572 {
16573 1721294 tile = o_tile+(clk&3);
16574
16575
8/9
✓ Branch 0 taken 214278 times.
✓ Branch 1 taken 217924 times.
✓ Branch 2 taken 215346 times.
✓ Branch 3 taken 215726 times.
✓ Branch 4 taken 213062 times.
✓ Branch 5 taken 214350 times.
✓ Branch 6 taken 215734 times.
✓ Branch 7 taken 214874 times.
✗ Branch 8 not taken.
1721294 switch(dir) //directions get screwed up after 8. *shrug*
16576 {
16577 case up: //u
16578 214278 flip=0;
16579 214278 break;
16580
16581 case down: //d
16582 217924 flip=0;
16583 217924 tile+=4;
16584 217924 break;
16585
16586 case left: //l
16587 215346 flip=0;
16588 215346 tile+=8;
16589 215346 break;
16590
16591 case right: //r
16592 215726 flip=0;
16593 215726 tile+=12;
16594 215726 break;
16595
16596 case l_up: //ul
16597 213062 flip=0;
16598 213062 tile+=20;
16599 213062 break;
16600
16601 case r_up: //ur
16602 214350 flip=0;
16603 214350 tile+=24;
16604 214350 break;
16605
16606 case l_down: //dl
16607 215734 flip=0;
16608 215734 tile+=28;
16609 215734 break;
16610
16611 case r_down: //dr
16612 214874 flip=0;
16613 214874 tile+=32;
16614 214874 break;
16615 }
16616 1721294 }
16617 else
16618 {
16619 306902 tile = o_tile+((clk&2)>>1);
16620 }
16621
16622
2/2
✓ Branch 0 taken 114856 times.
✓ Branch 1 taken 1913340 times.
2028196 if(clk>=0)
16623 1913340 enemy::draw(dest);
16624 2028196 }
16625
16626
16627 102 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
16628 102 {
16629 102 adjusted=false;
16630
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 dir=(zc_oldrand()&7)+8;
16631
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 step=0.25;
16632 102 clk4 = 0;
16633 102 clk5 = 0;
16634 //flycnt=6; flycnt2=0;
16635 102 flycnt=dmisc1;
16636 102 flycnt2=0; // PatraBS doesn't have inner rings!
16637 102 loopcnt=0;
16638
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 init_size_flags();
16639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16640
16641 //nets+4480;
16642 102 }
16643
16644 35963 bool ePatraBS::animate(int32_t index)
16645 {
16646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35963 times.
35963 if(switch_hooked) return enemy::animate(index);
16647
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 35723 times.
35963 if(dying)
16648 240 return Dead(index);
16649
16650
2/2
✓ Branch 0 taken 31705 times.
✓ Branch 1 taken 4018 times.
35723 if(clk==0)
16651 {
16652 4018 removearmos(x,y,ffcactivated);
16653 4018 }
16654
16655 35723 variable_walk_8(rate,homing,hrate,spw_floater);
16656
16657
2/2
✓ Branch 0 taken 35387 times.
✓ Branch 1 taken 336 times.
35723 if(++clk2>90)
16658 {
16659 336 clk2=0;
16660
16661
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 159 times.
336 if(loopcnt)
16662 177 --loopcnt;
16663 else
16664 {
16665
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 75 times.
159 if((misc%dmisc6)==0)
16666 84 loopcnt=dmisc7;
16667 }
16668
16669 336 ++misc;
16670 336 }
16671
16672 // double size=1;;
16673
2/2
✓ Branch 0 taken 153472 times.
✓ Branch 1 taken 35723 times.
189195 for(int32_t i=index+1; i<index+flycnt+1; i++)
16674 {
16675
2/2
✓ Branch 0 taken 152860 times.
✓ Branch 1 taken 612 times.
153472 if(!adjusted)
16676 {
16677 612 ((enemy*)guys.spr(i))->hp=dmisc3;
16678
16679
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(get_qr(qr_NEWENEMYTILES))
16680 {
16681 612 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
16682 612 }
16683 else
16684 {
16685 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16686 }
16687
16688 612 ((enemy*)guys.spr(i))->cs = dmisc9;
16689 612 }
16690
16691
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 153368 times.
153472 if(((enemy*)guys.spr(i))->hp <= 0)
16692 {
16693
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 104 times.
235 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16694 {
16695 131 guys.swap(j,j+1);
16696 131 }
16697
16698 104 --flycnt;
16699 104 }
16700 else
16701 {
16702 153368 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16703
1/2
✓ Branch 0 taken 153368 times.
✗ Branch 1 not taken.
153368 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
16704 153368 temp_x = zc::math::Cos(a2+PI/2)*45;
16705 153368 temp_y = -zc::math::Sin(a2+PI/2)*45;
16706
16707
2/2
✓ Branch 0 taken 77643 times.
✓ Branch 1 taken 75725 times.
153368 if(loopcnt>0)
16708 {
16709 77643 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
16710
1/2
✓ Branch 0 taken 77643 times.
✗ Branch 1 not taken.
77643 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
16711 77643 }
16712 else
16713 {
16714 75725 guys.spr(i)->x = temp_x;
16715 75725 guys.spr(i)->y = temp_y;
16716 }
16717
16718 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16719 153368 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16720
16721
4/4
✓ Branch 0 taken 29178 times.
✓ Branch 1 taken 124190 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18812 times.
153368 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16722 {
16723 18812 guys.spr(i)->dir=l_down;
16724 18812 }
16725
4/4
✓ Branch 0 taken 29205 times.
✓ Branch 1 taken 105351 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18839 times.
134556 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16726 {
16727 18839 guys.spr(i)->dir=left;
16728 18839 }
16729
4/4
✓ Branch 0 taken 29168 times.
✓ Branch 1 taken 86549 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18802 times.
115717 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16730 {
16731 18802 guys.spr(i)->dir=l_up;
16732 18802 }
16733
4/4
✓ Branch 0 taken 30509 times.
✓ Branch 1 taken 66406 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 20143 times.
96915 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16734 {
16735 20143 guys.spr(i)->dir=up;
16736 20143 }
16737
4/4
✓ Branch 0 taken 28883 times.
✓ Branch 1 taken 47889 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18517 times.
76772 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16738 {
16739 18517 guys.spr(i)->dir=r_up;
16740 18517 }
16741
4/4
✓ Branch 0 taken 29145 times.
✓ Branch 1 taken 29110 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18779 times.
58255 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16742 {
16743 18779 guys.spr(i)->dir=right;
16744 18779 }
16745
4/4
✓ Branch 0 taken 29358 times.
✓ Branch 1 taken 10118 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18992 times.
39476 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16746 {
16747 18992 guys.spr(i)->dir=r_down;
16748 18992 }
16749 else
16750 {
16751 20484 guys.spr(i)->dir=down;
16752 }
16753
16754 153368 guys.spr(i)->x += x;
16755 153368 guys.spr(i)->y += y;
16756 }
16757 153472 }
16758
16759 35723 adjusted=true;
16760 35723 return enemy::animate(index);
16761 35963 }
16762
16763 72874 void ePatraBS::draw(BITMAP *dest)
16764 {
16765 72874 tile=o_tile;
16766
16767
1/2
✓ Branch 0 taken 72874 times.
✗ Branch 1 not taken.
72874 if(get_qr(qr_NEWENEMYTILES))
16768 {
16769 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16770 72874 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
16771
16772
4/4
✓ Branch 0 taken 27164 times.
✓ Branch 1 taken 45710 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 19146 times.
72874 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16773 {
16774 19146 lookat=l_down;
16775 19146 }
16776
4/4
✓ Branch 0 taken 26316 times.
✓ Branch 1 taken 27412 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 18298 times.
53728 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16777 {
16778 18298 lookat=down;
16779 18298 }
16780
4/4
✓ Branch 0 taken 21642 times.
✓ Branch 1 taken 13788 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 13624 times.
35430 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16781 {
16782 13624 lookat=r_down;
16783 13624 }
16784
4/4
✓ Branch 0 taken 15510 times.
✓ Branch 1 taken 6296 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 7492 times.
21806 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16785 {
16786 7492 lookat=right;
16787 7492 }
16788
4/4
✓ Branch 0 taken 9188 times.
✓ Branch 1 taken 5126 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 1170 times.
14314 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16789 {
16790 1170 lookat=r_up;
16791 1170 }
16792
4/4
✓ Branch 0 taken 8982 times.
✓ Branch 1 taken 4162 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 964 times.
13144 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16793 {
16794 964 lookat=up;
16795 964 }
16796
4/4
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 2462 times.
✓ Branch 2 taken 1700 times.
✓ Branch 3 taken 8018 times.
12180 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16797 {
16798 1700 lookat=l_up;
16799 1700 }
16800 else
16801 {
16802 10480 lookat=left;
16803 }
16804
16805
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 18298 times.
✓ Branch 3 taken 10480 times.
✓ Branch 4 taken 7492 times.
✓ Branch 5 taken 1700 times.
✓ Branch 6 taken 1170 times.
✓ Branch 7 taken 19146 times.
✓ Branch 8 taken 13624 times.
72874 switch(lookat) //directions get screwed up after 8. *shrug*
16806 {
16807 case up: //u
16808 964 flip=0;
16809 964 break;
16810
16811 case down: //d
16812 18298 flip=0;
16813 18298 tile+=8;
16814 18298 break;
16815
16816 case left: //l
16817 10480 flip=0;
16818 10480 tile+=40;
16819 10480 break;
16820
16821 case right: //r
16822 7492 flip=0;
16823 7492 tile+=48;
16824 7492 break;
16825
16826 case l_up: //ul
16827 1700 flip=0;
16828 1700 tile+=80;
16829 1700 break;
16830
16831 case r_up: //ur
16832 1170 flip=0;
16833 1170 tile+=88;
16834 1170 break;
16835
16836 case l_down: //dl
16837 19146 flip=0;
16838 19146 tile+=120;
16839 19146 break;
16840
16841 case r_down: //dr
16842 13624 flip=0;
16843 13624 tile+=128;
16844 13624 break;
16845 }
16846
16847 72874 tile+=(2*(clk&3));
16848 72874 xofs-=8;
16849 72874 yofs-=8;
16850 72874 drawblock(dest,15);
16851 72874 xofs+=8;
16852 72874 yofs+=8;
16853 72874 }
16854 else
16855 {
16856 flip=(clk&1);
16857 xofs-=8;
16858 yofs-=8;
16859 enemy::draw(dest);
16860 xofs+=16;
16861 enemy::draw(dest);
16862 yofs+=16;
16863 enemy::draw(dest);
16864 xofs-=16;
16865 enemy::draw(dest);
16866 xofs+=8;
16867 yofs-=8;
16868 }
16869 72874 }
16870
16871 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
16872 {
16873 int32_t ret = enemy::defend(wpnId, power, edef);
16874
16875 if(ret < 0 && (flycnt||flycnt2))
16876 return 0;
16877
16878 return ret;
16879 }
16880
16881 142 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16882 {
16883 142 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16884
16885
5/6
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60 times.
142 if(ret < 0 && (flycnt||flycnt2))
16886 81 return 0;
16887
16888 61 return ret;
16889 142 }
16890
16891 102 void ePatraBS::init_size_flags()
16892 {
16893 102 SIZEflags = d->SIZEflags;
16894
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16895 // al_trace("Enemy txsz:%i\n", txsz);
16896
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
16897
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
16898 102 else hit_width = 32;
16899
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
16900
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
16901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
16902 102 else hxofs = -8;
16903
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
16904 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16905
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
16906
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16907 {
16908 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16909 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16910 }
16911
16912
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
16913 102 }
16914
16915 1224 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
16916 612 {
16917 //cs=csBOSS;
16918 612 item_set=0;
16919 612 misc=clk;
16920 612 clk = -((misc*21)>>1)-1;
16921 612 clk4 = 0;
16922 612 clk5 = 0;
16923
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16924 612 int32_t prntSIZEflags = prntenemy->SIZEflags;
16925
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16926 // al_trace("Enemy txsz:%i\n", txsz);
16927
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16928
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
16929 612 else hit_width=16;
16930
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
16931 612 else hit_height=16;
16932
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16933
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if ( (prntSIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16935 612 else hyofs=2;
16936 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16937
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
16939 {
16940 yofs = (int32_t)prntenemy->yofs;
16941 }
16942
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16943
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
16944
16945 612 bgsfx=-1;
16946 612 mainguy=count_enemy=false;
16947 612 deadsfx = WAV_EDEAD;
16948 612 hitsfx = WAV_EHIT;
16949
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 flags &= ~guy_never_return;
16950 612 isCore = false;
16951 612 }
16952
16953 155090 bool esPatraBS::animate(int32_t index)
16954 {
16955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155090 times.
155090 if(switch_hooked) return enemy::animate(index);
16956
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 153538 times.
155090 if(dying)
16957 1552 return Dead(index);
16958
16959 153538 return enemy::animate(index);
16960 155090 }
16961
16962 315868 void esPatraBS::draw(BITMAP *dest)
16963 {
16964 315868 tile=o_tile;
16965
16966
1/2
✓ Branch 0 taken 315868 times.
✗ Branch 1 not taken.
315868 if(get_qr(qr_NEWENEMYTILES))
16967 {
16968
8/9
✓ Branch 0 taken 41612 times.
✓ Branch 1 taken 42622 times.
✓ Branch 2 taken 37916 times.
✓ Branch 3 taken 38458 times.
✓ Branch 4 taken 38564 times.
✓ Branch 5 taken 38568 times.
✓ Branch 6 taken 38662 times.
✓ Branch 7 taken 39466 times.
✗ Branch 8 not taken.
315868 switch(dir) //directions get screwed up after 8. *shrug*
16969 {
16970 case up: //u
16971 41612 flip=0;
16972 41612 break;
16973
16974 case down: //d
16975 42622 flip=0;
16976 42622 tile+=4;
16977 42622 break;
16978
16979 case left: //l
16980 37916 flip=0;
16981 37916 tile+=8;
16982 37916 break;
16983
16984 case right: //r
16985 38458 flip=0;
16986 38458 tile+=12;
16987 38458 break;
16988
16989 case l_up: //ul
16990 38564 flip=0;
16991 38564 tile+=20;
16992 38564 break;
16993
16994 case r_up: //ur
16995 38568 flip=0;
16996 38568 tile+=24;
16997 38568 break;
16998
16999 case l_down: //dl
17000 38662 flip=0;
17001 38662 tile+=28;
17002 38662 break;
17003
17004 case r_down: //dr
17005 39466 flip=0;
17006 39466 tile+=32;
17007 39466 break;
17008 }
17009
17010 315868 tile += ((clk&6)>>1);
17011 315868 }
17012 else
17013 {
17014 tile += (clk&4)?1:0;
17015 }
17016
17017
2/2
✓ Branch 0 taken 32116 times.
✓ Branch 1 taken 283752 times.
315868 if(clk>=0)
17018 283752 enemy::draw(dest);
17019 315868 }
17020
17021 241822 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
17022 {
17023
4/6
✓ Branch 0 taken 135636 times.
✓ Branch 1 taken 106186 times.
✓ Branch 2 taken 135636 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135636 times.
✗ Branch 5 not taken.
241822 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
17024
4/8
✓ Branch 0 taken 241822 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 241822 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 241822 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 241822 times.
✗ Branch 7 not taken.
241822 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
17025
1/2
✓ Branch 0 taken 241822 times.
✗ Branch 1 not taken.
241822 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
17026 241822 }
17027
17028 74329 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
17029 {
17030 // Kludge
17031
4/8
✓ Branch 0 taken 74329 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74329 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74329 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 74329 times.
✗ Branch 7 not taken.
74329 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
17032 74329 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
17033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74329 times.
74329 delete w;
17034 74329 return ret;
17035 }
17036
17037 9138 void enemy_scored(int32_t index)
17038 {
17039 9138 ((enemy*)guys.spr(index))->scored=true;
17040 9138 }
17041
17042 2178 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
17043 {
17044
6/10
✓ Branch 0 taken 2178 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2178 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2178 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 272 times.
✓ Branch 7 taken 1906 times.
✓ Branch 8 taken 2178 times.
✗ Branch 9 not taken.
2178 guy *g = new guy((zfix)x,(zfix)(y+(isdungeon()?1:0)),id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
17045
5/6
✓ Branch 0 taken 1268 times.
✓ Branch 1 taken 910 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1264 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
2178 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
17046 {
17047 4 g->o_tile = parentscr->guytile;
17048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(g->o_tile != 0)
17049 4 g->flags &= ~guy_invisible;
17050 4 g->cs = parentscr->guycs;
17051 4 }
17052 2178 guys.add(g);
17053 2178 }
17054
17055 23572 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17056 {
17057
4/8
✓ Branch 0 taken 23572 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23572 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23572 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23572 times.
✗ Branch 7 not taken.
23572 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
17058 23572 items.add(i);
17059 23572 }
17060
17061 150 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
17062 {
17063
5/10
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 150 times.
✗ Branch 9 not taken.
150 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
17064 150 items.add(i);
17065 150 }
17066
17067 3 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17068 {
17069
5/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
3 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
17070 3 items.add(i);
17071 3 }
17072
17073 96 void kill_em_all()
17074 {
17075
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 96 times.
449 for(int32_t i=0; i<guys.Count(); i++)
17076 {
17077 353 enemy *e = ((enemy*)guys.spr(i));
17078
17079
3/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
353 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17080
17081 323 e->kickbucket();
17082 323 }
17083 96 }
17084
17085 bool can_kill_em_all()
17086 {
17087 for(int32_t i=0; i<guys.Count(); i++)
17088 {
17089 enemy *e = ((enemy*)guys.spr(i));
17090
17091 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17092 if(e->superman) continue;
17093 return true;
17094 }
17095 return false;
17096 }
17097
17098 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
17099 // For Hero's hit detection. Don't count them if they are stunned or are guys.
17100 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17101 {
17102 for(int32_t i=0; i<guys.Count(); i++)
17103 {
17104 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17105 {
17106 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
17107 &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
17108 {
17109 return i;
17110 }
17111 }
17112 }
17113
17114 return -1;
17115 }
17116
17117 13008633 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17118 {
17119
4/4
✓ Branch 0 taken 16502 times.
✓ Branch 1 taken 12992131 times.
✓ Branch 2 taken 33607435 times.
✓ Branch 3 taken 12977956 times.
46585391 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
17120 {
17121
2/2
✓ Branch 0 taken 30677 times.
✓ Branch 1 taken 33576758 times.
33607435 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17122 {
17123 30677 return i;
17124 }
17125 33576758 }
17126
17127 12977956 return -1;
17128 13008633 }
17129
17130 // For Hero's hit detection. Count them if they are dying.
17131 52199 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17132 {
17133 52199 enemy *e = (enemy*)guys.spr(index);
17134
3/4
✓ Branch 0 taken 52199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27828 times.
✓ Branch 3 taken 24371 times.
52199 if(!e || e->hp > 0)
17135 27828 return -1;
17136
17137 24371 bool d = e->dying;
17138 24371 int32_t hc = e->hclk;
17139 24371 e->dying = false;
17140 24371 e->hclk = 0;
17141 24371 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
17142 24371 e->dying = d;
17143 24371 e->hclk = hc;
17144
17145
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 24214 times.
24371 return hit ? index : -1;
17146 52199 }
17147
17148 14168697 bool hasMainGuy()
17149 {
17150
2/2
✓ Branch 0 taken 15393915 times.
✓ Branch 1 taken 5529586 times.
20923501 for(int32_t i=0; i<guys.Count(); i++)
17151 {
17152
2/2
✓ Branch 0 taken 8639111 times.
✓ Branch 1 taken 6754804 times.
15393915 if(((enemy*)guys.spr(i))->mainguy)
17153 {
17154 8639111 return true;
17155 }
17156 6754804 }
17157
17158 5529586 return false;
17159 14168697 }
17160
17161 138 void EatHero(int32_t index)
17162 {
17163 138 ((eStalfos*)guys.spr(index))->eathero();
17164 138 }
17165
17166 9 void GrabHero(int32_t index)
17167 {
17168 9 ((eWallM*)guys.spr(index))->grabhero();
17169 9 }
17170
17171 1338 bool CarryHero()
17172 {
17173
1/2
✓ Branch 0 taken 3933 times.
✗ Branch 1 not taken.
3933 for(int32_t i=0; i<guys.Count(); i++)
17174 {
17175
2/2
✓ Branch 0 taken 2090 times.
✓ Branch 1 taken 1843 times.
3933 if(((guy*)(guys.spr(i)))->family==eeWALLM)
17176 {
17177
2/2
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 505 times.
1843 if(((eWallM*)guys.spr(i))->hashero)
17178 {
17179 1338 Hero.x=guys.spr(i)->x;
17180 1338 Hero.y=guys.spr(i)->y;
17181 1338 return ((eWallM*)guys.spr(i))->misc > 0;
17182 }
17183 505 }
17184
17185 // Like Likes currently can't carry Hero.
17186 /*
17187 if(((guy*)(guys.spr(i)))->family==eeLIKE)
17188 {
17189 if(((eLikeLike*)guys.spr(i))->hashero)
17190 {
17191 Hero.x=guys.spr(i)->x;
17192 Hero.y=guys.spr(i)->y;
17193 return (true);
17194 }
17195 }*/
17196 2595 }
17197
17198 return false;
17199 1338 }
17200
17201 // Move item with guy
17202 void movefairy(zfix &x,zfix &y,int32_t misc)
17203 {
17204 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17205
17206 if(i!=-1)
17207 {
17208 x = guys.spr(i)->x;
17209 y = guys.spr(i)->y;
17210 }
17211 }
17212
17213 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17214 void movefairy2(zfix x,zfix y,int32_t misc)
17215 {
17216 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17217
17218 if(i!=-1)
17219 {
17220 guys.spr(i)->x = x;
17221 guys.spr(i)->y = y;
17222 }
17223 }// Move item with guy
17224
17225 60438 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
17226 {
17227 60438 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17228
17229
1/2
✓ Branch 0 taken 60438 times.
✗ Branch 1 not taken.
60438 if(fairy)
17230 {
17231 60438 x = fairy->x;
17232 60438 y = fairy->y;
17233 60438 }
17234 60438 }
17235
17236 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17237 404 void movefairynew2(zfix x,zfix y, item const &itemfairy)
17238 {
17239 404 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17240
17241
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 if(fairy)
17242 {
17243 404 fairy->x = x;
17244 404 fairy->y = y;
17245 404 }
17246 404 }
17247
17248 void killfairy(int32_t misc)
17249 {
17250 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17251 guys.del(i);
17252 }
17253
17254 217 int32_t getGuyIndex(const int32_t eid)
17255 {
17256
1/2
✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
826 for(word i = 0; i < guys.Count(); i++)
17257 {
17258
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 609 times.
826 if(guys.spr(i)->getUID() == eid)
17259 217 return i;
17260 609 }
17261
17262 return -1;
17263 217 }
17264
17265 217 void killfairynew(item const &itemfairy)
17266 {
17267 217 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17268
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
17269 217 }
17270
17271 //Should probably change this to return an 'enemy*', null on failure -Em
17272 21701 int32_t addenemy(int32_t x,int32_t y,int32_t id,int32_t clk)
17273 {
17274 21701 return addenemy(x,y,0,id,clk);
17275 }
17276
17277 1965 int32_t addchild(int32_t x,int32_t y,int32_t id,int32_t clk, int32_t parent_scriptUID)
17278 {
17279 1965 return addchild(x,y,0,id,clk, parent_scriptUID);
17280 }
17281
17282 1997 int32_t addchild(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, int32_t parent_scriptUID)
17283 {
17284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1997 times.
1997 if(id <= 0) return 0;
17285
17286 1997 int32_t ret = 0;
17287 1997 sprite *e=NULL;
17288 1997 al_trace("Adding child\n");
17289
17290
6/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1865 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1997 switch(guysbuf[id&0xFFF].family)
17291 {
17292 //Fixme: possible enemy memory leak. (minor)
17293 case eeWALK:
17294
3/6
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
110 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17295 110 break;
17296
17297 case eeLEV:
17298 e = new eLeever((zfix)x,(zfix)y,id,clk);
17299 break;
17300
17301 case eeTEK:
17302 e = new eTektite((zfix)x,(zfix)y,id,clk);
17303 break;
17304
17305 case eePEAHAT:
17306 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17307 break;
17308
17309 case eeZORA:
17310 e = new eZora((zfix)x,(zfix)y,id,clk);
17311 break;
17312
17313 case eeGHINI:
17314 e = new eGhini((zfix)x,(zfix)y,id,clk);
17315 break;
17316
17317 case eeKEESE:
17318
3/6
✓ Branch 0 taken 1865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1865 times.
✗ Branch 5 not taken.
1865 e = new eKeese((zfix)x,(zfix)y,id,clk);
17319 1865 break;
17320
17321 case eeWIZZ:
17322
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17323 15 break;
17324
17325 case eePROJECTILE:
17326 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17327 break;
17328
17329 case eeWALLM:
17330 e = new eWallM((zfix)x,(zfix)y,id,clk);
17331 break;
17332
17333 case eeAQUA:
17334 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17335 break;
17336
17337 case eeMOLD:
17338 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17339 break;
17340
17341 case eeMANHAN:
17342
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17343 1 break;
17344
17345 case eeGLEEOK:
17346 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17347 break;
17348
17349 case eeGHOMA:
17350 e = new eGohma((zfix)x,(zfix)y,id,clk);
17351 break;
17352
17353 case eeLANM:
17354 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17355 break;
17356
17357 case eeGANON:
17358 e = new eGanon((zfix)x,(zfix)y,id,clk);
17359 break;
17360
17361 case eeFAIRY:
17362 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17363 break;
17364
17365 case eeFIRE:
17366
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eFire((zfix)x,(zfix)y,id,clk);
17367 2 break;
17368
17369 case eeOTHER:
17370 e = new eOther((zfix)x,(zfix)y,id,clk);
17371 break;
17372
17373
17374 case eeSCRIPT01:
17375 case eeSCRIPT02:
17376 case eeSCRIPT03:
17377 case eeSCRIPT04:
17378 case eeSCRIPT05:
17379 case eeSCRIPT06:
17380 case eeSCRIPT07:
17381 case eeSCRIPT08:
17382 case eeSCRIPT09:
17383 case eeSCRIPT10:
17384 case eeSCRIPT11:
17385 case eeSCRIPT12:
17386 case eeSCRIPT13:
17387 case eeSCRIPT14:
17388 case eeSCRIPT15:
17389 case eeSCRIPT16:
17390 case eeSCRIPT17:
17391 case eeSCRIPT18:
17392 case eeSCRIPT19:
17393 case eeSCRIPT20:
17394 {
17395 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17396 {
17397 e = new eScript((zfix)x,(zfix)y,id,clk);
17398 break;
17399 }
17400 else return 0;
17401 }
17402
17403 case eeFFRIENDLY01:
17404 case eeFFRIENDLY02:
17405 case eeFFRIENDLY03:
17406 case eeFFRIENDLY04:
17407 case eeFFRIENDLY05:
17408 case eeFFRIENDLY06:
17409 case eeFFRIENDLY07:
17410 case eeFFRIENDLY08:
17411 case eeFFRIENDLY09:
17412 case eeFFRIENDLY10:
17413 {
17414 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17415 {
17416 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17417 }
17418 else return 0;
17419
17420 }
17421
17422 case eeSPINTILE:
17423 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17424 break;
17425
17426 // and these enemies use the misc10/misc2 value
17427 case eeROCK:
17428 {
17429 switch(guysbuf[id&0xFFF].attributes[9])
17430 {
17431 case 1:
17432 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17433 break;
17434
17435 case 0:
17436 default:
17437 e = new eRock((zfix)x,(zfix)y,id,clk);
17438 break;
17439 }
17440
17441 break;
17442 }
17443
17444 case eeTRAP:
17445 {
17446 switch(guysbuf[id&0xFFF].attributes[1])
17447 {
17448 case 1:
17449 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17450 break;
17451
17452 case 0:
17453 default:
17454 e = new eTrap((zfix)x,(zfix)y,id,clk);
17455 break;
17456 }
17457
17458 break;
17459 }
17460
17461 case eeDONGO:
17462 {
17463 switch(guysbuf[id&0xFFF].attributes[9])
17464 {
17465 case 1:
17466 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17467 break;
17468
17469 case 0:
17470 default:
17471 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17472 break;
17473 }
17474
17475 break;
17476 }
17477
17478 case eeDIG:
17479 {
17480
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].attributes[9])
17481 {
17482 case 1:
17483 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17484 break;
17485
17486 4 case 0:
17487 default:
17488
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17489 4 break;
17490 }
17491
17492 4 break;
17493 }
17494
17495 case eePATRA:
17496 {
17497 switch(guysbuf[id&0xFFF].attributes[9])
17498 {
17499 case 1:
17500 if (get_qr(qr_HARDCODED_BS_PATRA))
17501 {
17502 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17503 break;
17504 }
17505 [[fallthrough]];
17506 case 0:
17507 default:
17508 e = new ePatra((zfix)x,(zfix)y,id,clk);
17509 break;
17510 }
17511
17512 break;
17513 }
17514
17515 case eeGUY:
17516 {
17517 switch(guysbuf[id&0xFFF].attributes[9])
17518 {
17519 case 1:
17520 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17521 break;
17522
17523 case 0:
17524 default:
17525 e = new eNPC((zfix)x,(zfix)y,id,clk);
17526 break;
17527 }
17528
17529 break;
17530 }
17531
17532 case eeNONE:
17533 if(guysbuf[id&0xFFF].attributes[9] ==1)
17534 {
17535 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17536 break;
17537 break;
17538 }
17539 [[fallthrough]];
17540 default:
17541
17542 return 0;
17543 }
17544
17545 1997 ret++; // Made one enemy.
17546
17547
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
1997 if(z && canfall(id))
17548 {
17549 7 e->z = (zfix)z;
17550 7 }
17551
17552
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 7 times.
1997 ((enemy*)e)->ceiling = (z && canfall(id));
17553 1997 ((enemy*)e)->parent_script_UID = parent_scriptUID;
17554
17555
17556
1/2
✓ Branch 0 taken 1997 times.
✗ Branch 1 not taken.
1997 if(!guys.add(e))
17557 {
17558 return 0;
17559 }
17560
17561 // add segments of segmented enemies
17562 1997 int32_t c=0;
17563
17564
2/6
✓ Branch 0 taken 1996 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1997 switch(guysbuf[id&0xFFF].family)
17565 {
17566 case eeMOLD:
17567 {
17568 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17569 id &= 0xFFF;
17570
17571 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17572 {
17573 //christ this is messy -DD
17574 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17575
17576 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17577 {
17578 al_trace("Moldorm segment %d could not be created!\n",i+1);
17579
17580 for(int32_t j=0; j<i+1; j++)
17581 guys.del(guys.Count()-1);
17582
17583 return 0;
17584 }
17585
17586 if(i>0)
17587 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17588
17589 ret++;
17590 }
17591
17592 break;
17593 }
17594
17595 case eeLANM:
17596 {
17597 id &= 0xFFF;
17598 int32_t shft = guysbuf[id].attributes[1];
17599 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17600
17601 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17602 {
17603 al_trace("Lanmola segment 1 could not be created!\n");
17604 guys.del(guys.Count()-1);
17605 return 0;
17606 }
17607
17608 ret++;
17609
17610 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17611 {
17612 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17613 {
17614 al_trace("Lanmola segment %d could not be created!\n",i+1);
17615
17616 for(int32_t j=0; j<i+1; j++)
17617 guys.del(guys.Count()-1);
17618
17619 return 0;
17620 }
17621
17622 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17623 ret++;
17624 }
17625 }
17626 break;
17627
17628 case eeMANHAN:
17629 1 id &= 0xFFF;
17630
17631
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17632 {
17633
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17634 {
17635 al_trace("Manhandla head %d could not be created!\n",i+1);
17636
17637 for(int32_t j=0; j<i+1; j++)
17638 {
17639 guys.del(guys.Count()-1);
17640 }
17641
17642 return 0;
17643 }
17644
17645 4 ret++;
17646 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17647 4 }
17648
17649 1 break;
17650
17651 case eeGLEEOK:
17652 {
17653 id &= 0xFFF;
17654
17655 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17656 {
17657 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
17658 {
17659 al_trace("Gleeok head %d could not be created!\n",i+1);
17660
17661 for(int32_t j=0; j<i+1; j++)
17662 {
17663 guys.del(guys.Count()-1);
17664 }
17665
17666 return false;
17667 }
17668
17669 c-=guysbuf[id].attributes[3];
17670 ret++;
17671 }
17672 }
17673 break;
17674
17675
17676 case eePATRA:
17677 {
17678 id &= 0xFFF;
17679 int32_t outeyes = 0;
17680
17681 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17682 {
17683 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17684 {
17685 al_trace("Patra outer eye %d could not be created!\n",i+1);
17686
17687 for(int32_t j=0; j<i+1; j++)
17688 guys.del(guys.Count()-1);
17689
17690 return 0;
17691 }
17692 else
17693 outeyes++;
17694
17695 ret++;
17696 }
17697
17698 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17699 {
17700 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17701 {
17702 al_trace("Patra inner eye %d could not be created!\n",i+1);
17703
17704 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17705 guys.del(guys.Count()-1);
17706
17707 return 0;
17708 }
17709
17710 ret++;
17711 }
17712
17713 break;
17714 }
17715 }
17716
17717 1997 return ret;
17718 1997 }
17719
17720 // Returns number of enemies/segments created
17721 101430 int32_t addenemy(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
17722 {
17723 101430 int32_t realid = id&0xFFF;
17724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101430 times.
101430 if( realid > MAXGUYS )
17725 {
17726 return 0;
17727 }
17728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101430 times.
101430 if(id <= 0) return 0;
17729
17730 101430 int32_t ret = 0;
17731 101430 sprite *e=NULL;
17732
17733
28/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50004 times.
✓ Branch 4 taken 3942 times.
✓ Branch 5 taken 5196 times.
✓ Branch 6 taken 1825 times.
✓ Branch 7 taken 2765 times.
✓ Branch 8 taken 461 times.
✓ Branch 9 taken 11717 times.
✓ Branch 10 taken 5311 times.
✓ Branch 11 taken 4429 times.
✓ Branch 12 taken 998 times.
✓ Branch 13 taken 126 times.
✓ Branch 14 taken 618 times.
✓ Branch 15 taken 149 times.
✓ Branch 16 taken 168 times.
✓ Branch 17 taken 93 times.
✓ Branch 18 taken 420 times.
✓ Branch 19 taken 13 times.
✓ Branch 20 taken 730 times.
✓ Branch 21 taken 757 times.
✓ Branch 22 taken 7314 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 384 times.
✓ Branch 25 taken 2432 times.
✓ Branch 26 taken 251 times.
✓ Branch 27 taken 403 times.
✓ Branch 28 taken 292 times.
✓ Branch 29 taken 5 times.
✓ Branch 30 taken 533 times.
101430 switch(guysbuf[id&0xFFF].family)
17734 {
17735 //Fixme: possible enemy memory leak. (minor)
17736 case eeWALK:
17737
3/6
✓ Branch 0 taken 50004 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50004 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50004 times.
✗ Branch 5 not taken.
50004 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17738 50004 break;
17739
17740 case eeLEV:
17741
3/6
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3942 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3942 times.
✗ Branch 5 not taken.
3942 e = new eLeever((zfix)x,(zfix)y,id,clk);
17742 3942 break;
17743
17744 case eeTEK:
17745
3/6
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5196 times.
✗ Branch 5 not taken.
5196 e = new eTektite((zfix)x,(zfix)y,id,clk);
17746 5196 break;
17747
17748 case eePEAHAT:
17749
3/6
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
1825 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17750 1825 break;
17751
17752 case eeZORA:
17753
3/6
✓ Branch 0 taken 2765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2765 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2765 times.
✗ Branch 5 not taken.
2765 e = new eZora((zfix)x,(zfix)y,id,clk);
17754 2765 break;
17755
17756 case eeGHINI:
17757
3/6
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 461 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 461 times.
✗ Branch 5 not taken.
461 e = new eGhini((zfix)x,(zfix)y,id,clk);
17758 461 break;
17759
17760 case eeKEESE:
17761
3/6
✓ Branch 0 taken 11717 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11717 times.
✗ Branch 5 not taken.
11717 e = new eKeese((zfix)x,(zfix)y,id,clk);
17762 11717 break;
17763
17764 case eeWIZZ:
17765
3/6
✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5311 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5311 times.
✗ Branch 5 not taken.
5311 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17766 5311 break;
17767
17768 case eePROJECTILE:
17769
3/6
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4429 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4429 times.
✗ Branch 5 not taken.
4429 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17770 4429 break;
17771
17772 case eeWALLM:
17773
3/6
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 998 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 998 times.
✗ Branch 5 not taken.
998 e = new eWallM((zfix)x,(zfix)y,id,clk);
17774 998 break;
17775
17776 case eeAQUA:
17777
3/6
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
126 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17778 126 break;
17779
17780 case eeMOLD:
17781
6/12
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 618 times.
✓ Branch 6 taken 618 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 618 times.
✓ Branch 10 taken 618 times.
✗ Branch 11 not taken.
618 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17782 618 break;
17783
17784 case eeMANHAN:
17785
3/6
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
149 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17786 149 break;
17787
17788 case eeGLEEOK:
17789
7/12
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
✓ Branch 6 taken 152 times.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 152 times.
✓ Branch 10 taken 168 times.
✗ Branch 11 not taken.
168 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17790 168 break;
17791
17792 case eeGHOMA:
17793
3/6
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✗ Branch 5 not taken.
93 e = new eGohma((zfix)x,(zfix)y,id,clk);
17794 93 break;
17795
17796 case eeLANM:
17797
6/12
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 420 times.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 420 times.
✓ Branch 10 taken 420 times.
✗ Branch 11 not taken.
420 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17798 420 break;
17799
17800 case eeGANON:
17801
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 e = new eGanon((zfix)x,(zfix)y,id,clk);
17802 13 break;
17803
17804 case eeFAIRY:
17805
3/6
✓ Branch 0 taken 730 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 730 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 730 times.
✗ Branch 5 not taken.
730 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17806 730 break;
17807
17808 case eeFIRE:
17809
3/6
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 757 times.
✗ Branch 5 not taken.
757 e = new eFire((zfix)x,(zfix)y,id,clk);
17810 757 break;
17811
17812 case eeOTHER:
17813
3/6
✓ Branch 0 taken 7314 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7314 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7314 times.
✗ Branch 5 not taken.
7314 e = new eOther((zfix)x,(zfix)y,id,clk);
17814 7314 break;
17815
17816
17817 case eeSCRIPT01:
17818 case eeSCRIPT02:
17819 case eeSCRIPT03:
17820 case eeSCRIPT04:
17821 case eeSCRIPT05:
17822 case eeSCRIPT06:
17823 case eeSCRIPT07:
17824 case eeSCRIPT08:
17825 case eeSCRIPT09:
17826 case eeSCRIPT10:
17827 case eeSCRIPT11:
17828 case eeSCRIPT12:
17829 case eeSCRIPT13:
17830 case eeSCRIPT14:
17831 case eeSCRIPT15:
17832 case eeSCRIPT16:
17833 case eeSCRIPT17:
17834 case eeSCRIPT18:
17835 case eeSCRIPT19:
17836 case eeSCRIPT20:
17837 {
17838 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17839 {
17840 e = new eScript((zfix)x,(zfix)y,id,clk);
17841 break;
17842 }
17843 else return 0;
17844 }
17845
17846 case eeFFRIENDLY01:
17847 case eeFFRIENDLY02:
17848 case eeFFRIENDLY03:
17849 case eeFFRIENDLY04:
17850 case eeFFRIENDLY05:
17851 case eeFFRIENDLY06:
17852 case eeFFRIENDLY07:
17853 case eeFFRIENDLY08:
17854 case eeFFRIENDLY09:
17855 case eeFFRIENDLY10:
17856 {
17857 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17858 {
17859 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17860 }
17861 else return 0;
17862
17863 }
17864
17865 case eeSPINTILE:
17866
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17867 94 break;
17868
17869 // and these enemies use the misc10/misc2 value
17870 case eeROCK:
17871 {
17872
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 354 times.
384 switch(guysbuf[id&0xFFF].attributes[9])
17873 {
17874 case 1:
17875
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17876 30 break;
17877
17878 354 case 0:
17879 default:
17880
3/6
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 354 times.
✗ Branch 5 not taken.
354 e = new eRock((zfix)x,(zfix)y,id,clk);
17881 354 break;
17882 }
17883
17884 384 break;
17885 }
17886
17887 case eeTRAP:
17888 {
17889
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 1600 times.
2432 switch(guysbuf[id&0xFFF].attributes[1])
17890 {
17891 case 1:
17892
3/6
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
832 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17893 832 break;
17894
17895 1600 case 0:
17896 default:
17897
3/6
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1600 times.
✗ Branch 5 not taken.
1600 e = new eTrap((zfix)x,(zfix)y,id,clk);
17898 1600 break;
17899 }
17900
17901 2432 break;
17902 }
17903
17904 case eeDONGO:
17905 {
17906
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 203 times.
251 switch(guysbuf[id&0xFFF].attributes[9])
17907 {
17908 case 1:
17909
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17910 48 break;
17911
17912 203 case 0:
17913 default:
17914
3/6
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 203 times.
✗ Branch 5 not taken.
203 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17915 203 break;
17916 }
17917
17918 251 break;
17919 }
17920
17921 case eeDIG:
17922 {
17923
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 76 times.
403 switch(guysbuf[id&0xFFF].attributes[9])
17924 {
17925 case 1:
17926
3/6
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 327 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
327 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17927 327 break;
17928
17929 76 case 0:
17930 default:
17931
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17932 76 break;
17933 }
17934
17935 403 break;
17936 }
17937
17938 case eePATRA:
17939 {
17940
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 102 times.
292 switch(guysbuf[id&0xFFF].attributes[9])
17941 {
17942 case 1:
17943
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (get_qr(qr_HARDCODED_BS_PATRA))
17944 {
17945
3/6
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102 times.
✗ Branch 5 not taken.
102 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17946 102 break;
17947 }
17948 [[fallthrough]];
17949 190 case 0:
17950 default:
17951
3/6
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 190 times.
✗ Branch 5 not taken.
190 e = new ePatra((zfix)x,(zfix)y,id,clk);
17952 190 break;
17953 }
17954
17955 292 break;
17956 }
17957
17958 case eeGUY:
17959 {
17960
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 switch(guysbuf[id&0xFFF].attributes[9])
17961 {
17962 case 1:
17963 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17964 break;
17965
17966 5 case 0:
17967 default:
17968
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 e = new eNPC((zfix)x,(zfix)y,id,clk);
17969 5 break;
17970 }
17971
17972 5 break;
17973 }
17974
17975 case eeNONE:
17976
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(guysbuf[id&0xFFF].attributes[9] ==1)
17977 {
17978
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17979 533 break;
17980 break;
17981 }
17982 [[fallthrough]];
17983 default:
17984
17985 return 0;
17986 }
17987
17988 101430 ret++; // Made one enemy.
17989
17990
4/4
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 101299 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 106 times.
101430 if(z && canfall(id))
17991 {
17992 106 e->z = (zfix)z;
17993 106 }
17994
17995
2/2
✓ Branch 0 taken 101299 times.
✓ Branch 1 taken 131 times.
101430 ((enemy*)e)->ceiling = (z && canfall(id));
17996
17997
1/2
✓ Branch 0 taken 101430 times.
✗ Branch 1 not taken.
101430 if(!guys.add(e))
17998 {
17999 return 0;
18000 }
18001
18002 // add segments of segmented enemies
18003 101430 int32_t c=0;
18004
18005
6/6
✓ Branch 0 taken 99783 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 149 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 292 times.
101430 switch(guysbuf[id&0xFFF].family)
18006 {
18007 case eeMOLD:
18008 {
18009 618 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18010 618 id &= 0xFFF;
18011
18012
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3768 times.
✓ Branch 2 taken 3768 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3768 times.
✓ Branch 6 taken 3150 times.
✓ Branch 7 taken 618 times.
3768 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
18013 {
18014 //christ this is messy -DD
18015 3150 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
18016
18017
4/8
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3150 times.
✗ Branch 7 not taken.
3150 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
18018 {
18019 al_trace("Moldorm segment %d could not be created!\n",i+1);
18020
18021 for(int32_t j=0; j<i+1; j++)
18022 guys.del(guys.Count()-1);
18023
18024 return 0;
18025 }
18026
18027
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 2532 times.
3150 if(i>0)
18028 2532 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18029
18030 3150 ret++;
18031 3150 }
18032
18033 618 break;
18034 }
18035
18036 case eeLANM:
18037 {
18038 420 id &= 0xFFF;
18039 420 int32_t shft = guysbuf[id].attributes[1];
18040 420 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18041
18042
4/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
420 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
18043 {
18044 al_trace("Lanmola segment 1 could not be created!\n");
18045 guys.del(guys.Count()-1);
18046 return 0;
18047 }
18048
18049 420 ret++;
18050
18051
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2267 times.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2267 times.
✓ Branch 6 taken 1847 times.
✓ Branch 7 taken 420 times.
2267 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
18052 {
18053
4/8
✓ Branch 0 taken 1847 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1847 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1847 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1847 times.
✗ Branch 7 not taken.
1847 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
18054 {
18055 al_trace("Lanmola segment %d could not be created!\n",i+1);
18056
18057 for(int32_t j=0; j<i+1; j++)
18058 guys.del(guys.Count()-1);
18059
18060 return 0;
18061 }
18062
18063 1847 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18064 1847 ret++;
18065 1847 }
18066 }
18067 420 break;
18068
18069 case eeMANHAN:
18070 149 id &= 0xFFF;
18071
18072
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 149 times.
837 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
18073 {
18074
4/8
✓ Branch 0 taken 688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 688 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 688 times.
✗ Branch 7 not taken.
688 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
18075 {
18076 al_trace("Manhandla head %d could not be created!\n",i+1);
18077
18078 for(int32_t j=0; j<i+1; j++)
18079 {
18080 guys.del(guys.Count()-1);
18081 }
18082
18083 return 0;
18084 }
18085
18086 688 ret++;
18087 688 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
18088 688 }
18089
18090 149 break;
18091
18092 case eeGLEEOK:
18093 {
18094 168 id &= 0xFFF;
18095 168 eGleeok* parent = (eGleeok*)e;
18096
18097
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 701 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 669 times.
✓ Branch 6 taken 533 times.
✓ Branch 7 taken 168 times.
701 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
18098 {
18099
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
18100
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(!guys.add(head))
18101 {
18102 al_trace("Gleeok head %d could not be created!\n",i+1);
18103
18104 for(int32_t j=0; j<i+1; j++)
18105 {
18106 guys.del(guys.Count()-1);
18107 }
18108
18109 return false;
18110 }
18111
18112 533 head->necktile=parent->necktile;
18113 533 head->dummy_int[1]=parent->necktile;
18114
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 112 times.
533 if(get_qr(qr_NEWENEMYTILES))
18115 {
18116 421 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
18117 421 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
18118 421 }
18119 else
18120 {
18121 112 head->dummy_int[2]=parent->necktile+1; //connected head tile
18122 112 head->dummy_int[3]=parent->necktile+2; //flying head tile
18123 }
18124 533 head->tile = head->dummy_int[2];
18125
18126 533 c-=guysbuf[id].attributes[3];
18127 533 ret++;
18128 533 }
18129 }
18130 168 break;
18131
18132
18133 case eePATRA:
18134 {
18135 292 id &= 0xFFF;
18136 292 int32_t outeyes = 0;
18137
18138
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2248 times.
✓ Branch 2 taken 1956 times.
✓ Branch 3 taken 292 times.
2248 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
18139 {
18140
10/22
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 612 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 612 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 612 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1344 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1344 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1344 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1344 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1956 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
18141 {
18142 al_trace("Patra outer eye %d could not be created!\n",i+1);
18143
18144 for(int32_t j=0; j<i+1; j++)
18145 guys.del(guys.Count()-1);
18146
18147 return 0;
18148 }
18149 else
18150 1956 outeyes++;
18151
18152 1956 ret++;
18153 1956 }
18154
18155
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 292 times.
604 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
18156 {
18157
4/8
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 312 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 312 times.
✗ Branch 7 not taken.
312 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
18158 {
18159 al_trace("Patra inner eye %d could not be created!\n",i+1);
18160
18161 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
18162 guys.del(guys.Count()-1);
18163
18164 return 0;
18165 }
18166
18167 312 ret++;
18168 312 }
18169
18170 292 break;
18171 }
18172 }
18173
18174 101430 return ret;
18175 101430 }
18176
18177 1852748 bool isjumper(int32_t id)
18178 {
18179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1852748 times.
1852748 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18180 {
18181 return false;
18182 }
18183
3/3
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1750545 times.
✓ Branch 2 taken 102194 times.
1852748 switch(guysbuf[id&0xFFF].family)
18184 {
18185 case eeROCK:
18186 case eeTEK:
18187 9 return true;
18188
18189 case eeWALK:
18190
3/4
✓ Branch 0 taken 102194 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 89929 times.
102194 if(guysbuf[id&0xFFF].attributes[8] == e9tVIRE || guysbuf[id & 0xFFF].attributes[8] == e9tPOLSVOICE) return true;
18191 89929 }
18192
18193 1840474 return false;
18194 1852748 }
18195
18196
18197 291817 bool isfixedtogrid(int32_t id)
18198 {
18199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291817 times.
291817 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18200 {
18201 return false;
18202 }
18203
1/2
✓ Branch 0 taken 291817 times.
✗ Branch 1 not taken.
291817 switch(guysbuf[id&0xFFF].family)
18204 {
18205 case eeWALK:
18206 case eeLEV:
18207 case eeZORA:
18208 case eeDONGO:
18209 case eeGANON:
18210 case eeROCK:
18211 case eeGLEEOK:
18212 case eeAQUA:
18213 case eeLANM:
18214 return true;
18215 }
18216
18217 291817 return false;
18218 291817 }
18219
18220 // Can't fall, can have Z value.
18221 51778511 bool isflier(int32_t id)
18222 {
18223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51778511 times.
51778511 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18224 {
18225 return false;
18226 }
18227
2/2
✓ Branch 0 taken 45350654 times.
✓ Branch 1 taken 6427857 times.
51778511 switch(guysbuf[id&0xFFF].family) //id&0x0FFF)
18228 {
18229 case eePEAHAT:
18230 case eeKEESE:
18231 case eePATRA:
18232 case eeFAIRY:
18233 case eeGHINI:
18234
18235 // Could theoretically have their Z set by a script
18236 case eeFIRE:
18237 6427857 return true;
18238 break;
18239 }
18240
18241 45350654 return false;
18242 51778511 }
18243
18244 // Can't have Z position
18245 3711290 bool never_in_air(int32_t id)
18246 {
18247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3711290 times.
3711290 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18248 {
18249 return false;
18250 }
18251
2/2
✓ Branch 0 taken 3701740 times.
✓ Branch 1 taken 9550 times.
3711290 switch(guysbuf[id&0xFFF].family)
18252 {
18253 case eeMANHAN:
18254 case eeMOLD:
18255 case eeLANM:
18256 case eeGLEEOK:
18257 case eeZORA:
18258 case eeLEV:
18259 case eeAQUA:
18260 case eeROCK:
18261 case eeGANON:
18262 case eeTRAP:
18263 case eePROJECTILE:
18264 case eeSPINTILE:
18265 9550 return true;
18266 }
18267
18268 3701740 return false;
18269 3711290 }
18270
18271 2013509 bool canfall(int32_t id)
18272 {
18273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2013509 times.
2013509 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18274 {
18275 return false;
18276 }
18277
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2013469 times.
✓ Branch 2 taken 40 times.
2013509 switch(guysbuf[id&0xFFF].family)
18278 {
18279 case eeGUY:
18280 {
18281
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(id < eOCTO1S)
18282 40 return false;
18283
18284 switch(guysbuf[id&0xFFF].attributes[9])
18285 {
18286 case 1:
18287 case 2:
18288 return true;
18289
18290 case 0:
18291 case 3:
18292 default:
18293 return false;
18294 }
18295
18296 case eeGHOMA:
18297 case eeDIG:
18298 return false;
18299 }
18300 }
18301
18302
18303
4/4
✓ Branch 0 taken 2005033 times.
✓ Branch 1 taken 8436 times.
✓ Branch 2 taken 152285 times.
✓ Branch 3 taken 1852748 times.
2013469 return !never_in_air(id) && !isflier(id) && !isjumper(id);
18304 2013509 }
18305
18306 73536095 bool enemy::enemycanfall(int32_t id, bool checkgrav)
18307 {
18308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73536095 times.
73536095 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18309 {
18310 return false;
18311 }
18312 //Z_scripterrlog("canfall family is %d:\n", family);
18313 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & move_obeys_grav ? "true" : "false");
18314 //if ( family == eeFIRE && id >= eSTART )
18315 //{
18316 // Z_scripterrlog("eeFire\n");
18317 // return moveflags & move_obeys_grav; //'Other' enemy class, used by scripts. -Z
18318 //}
18319
18320 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
18321
18322
3/3
✓ Branch 0 taken 428935 times.
✓ Branch 1 taken 71040465 times.
✓ Branch 2 taken 2066695 times.
73536095 switch(guysbuf[id&0xFFF].family)
18323 {
18324 case eeGUY:
18325 {
18326
1/2
✓ Branch 0 taken 2066695 times.
✗ Branch 1 not taken.
2066695 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
18327 2066695 return false;
18328
18329 switch(guysbuf[id&0xFFF].attributes[9]) //I'm unsure what these specify off-hand. Needs better comments. -Z
18330 {
18331 case 1:
18332 case 2:
18333 return true;
18334
18335 case 0:
18336 case 3:
18337 default:
18338 return false;
18339 }
18340
18341 case eeGHOMA:
18342 case eeDIG:
18343 428935 return false;
18344 }
18345 }
18346
18347
2/2
✓ Branch 0 taken 38945357 times.
✓ Branch 1 taken 32095108 times.
71040465 if(!checkgrav) return true;
18348 38945357 return (moveflags & move_obeys_grav);
18349
18350 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
18351 // {
18352 // if ( moveflags & move_obeys_grav ) return true;
18353 // else return false;
18354 // }
18355 // else
18356 // {
18357 // return (moveflags & move_obeys_grav);
18358 // }
18359 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
18360 73536095 }
18361
18362 1266 void addfires()
18363 {
18364
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 455 times.
1266 if(!get_qr(qr_NOGUYFIRES))
18365 {
18366 455 int32_t bs = get_qr(qr_BSZELDA);
18367 455 addguy(bs? 64: 72,64,gFIRE,-17,false,nullptr);
18368 455 addguy(bs?176:168,64,gFIRE,-18,false,nullptr);
18369 455 }
18370 1266 }
18371
18372 35236 void loadguys()
18373 {
18374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35236 times.
35236 if(loaded_guys)
18375 return;
18376
18377 35236 loaded_guys=true;
18378
18379 35236 byte Guy=0;
18380 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18381 // Else use mITEM and ipONETIME
18382 35236 int32_t mf = (currscr>=128) ? mSPECIALITEM : mITEM;
18383 35236 int32_t onetime = (currscr>=128) ? ipONETIME2 : ipONETIME;
18384
18385 35236 repaircharge=0;
18386 35236 adjustmagic=false;
18387 35236 learnslash=false;
18388
18389
2/2
✓ Branch 0 taken 105708 times.
✓ Branch 1 taken 35236 times.
140944 for(int32_t i=0; i<3; i++)
18390 {
18391 105708 prices[i]=0;
18392 105708 }
18393
18394 35236 hasitem=0;
18395
18396 35236 mapscr* guyscr = tmpscr;
18397
4/4
✓ Branch 0 taken 904 times.
✓ Branch 1 taken 34332 times.
✓ Branch 2 taken 475 times.
✓ Branch 3 taken 429 times.
35236 if(currscr>=128 && DMaps[currdmap].flags&dmfGUYCAVES)
18398 {
18399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 429 times.
429 if(DMaps[currdmap].flags&dmfCAVES)
18400 {
18401 429 Guy=tmpscr[1].guy;
18402 429 guyscr = tmpscr+1;
18403 429 }
18404 429 }
18405 else
18406 {
18407 34807 Guy=tmpscr->guy;
18408
18409
4/4
✓ Branch 0 taken 34332 times.
✓ Branch 1 taken 475 times.
✓ Branch 2 taken 24137 times.
✓ Branch 3 taken 10195 times.
34807 if(currscr < 0x80 && (DMaps[currdmap].flags&dmfVIEWMAP))
18410 10195 game->maps[(currmap*MAPSCRSNORMAL)+currscr] |= mVISITED; // mark as visited
18411 }
18412
18413 35236 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18414 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18415
4/4
✓ Branch 0 taken 3844 times.
✓ Branch 1 taken 31392 times.
✓ Branch 2 taken 2538 times.
✓ Branch 3 taken 1306 times.
35236 if(Guy && ((currscr>=128) == !!(DMaps[currdmap].flags&dmfGUYCAVES)))
18416 {
18417
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1295 times.
1306 if(tmpscr->room==rZELDA)
18418 {
18419 11 addguy(120,72,Guy,-15,true,guyscr);
18420 11 guys.spr(0)->hxofs=1000;
18421 11 addenemy(128,96,eFIRE,-15);
18422 11 addenemy(112,96,eFIRE,-15);
18423 11 addenemy(96,120,eFIRE,-15);
18424 11 addenemy(144,120,eFIRE,-15);
18425 11 return;
18426 }
18427
18428
2/2
✓ Branch 0 taken 1291 times.
✓ Branch 1 taken 4 times.
2586 bool ffire = oldguy
18429
2/2
✓ Branch 0 taken 1266 times.
✓ Branch 1 taken 25 times.
1291 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18430 4 : (guyscr->roomflags&RFL_GUYFIRES);
18431
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1266 times.
1295 if(ffire)
18432 1266 addfires();
18433
18434
2/2
✓ Branch 0 taken 872 times.
✓ Branch 1 taken 423 times.
1295 if(currscr>=128)
18435
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 410 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
436 if(getmapflag() && !(tmpscr->flags9&fBELOWRETURN))
18436 13 Guy=0;
18437
18438
4/6
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 1083 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 45 times.
1295 switch(tmpscr->room)
18439 {
18440 case rSP_ITEM:
18441 case rGRUMBLE:
18442 case rBOMBS:
18443 case rARROWS:
18444 case rSWINDLE:
18445 case rMUPGRADE:
18446 case rLEARNSLASH:
18447 case rTAKEONE:
18448
8/8
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 49 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 41 times.
166 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18449 55 Guy=0;
18450
18451 166 break;
18452
18453 case rREPAIR:
18454 if (get_qr(qr_OLD_DOORREPAIR)) break;
18455 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18456 Guy=0;
18457
18458 break;
18459 case rRP_HC:
18460 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18461 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18462 Guy=0;
18463
18464 break;
18465 case rMONEY:
18466
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18467 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18468 Guy=0;
18469
18470 break;
18471
18472 case rTRIFORCE:
18473 {
18474 45 int32_t tc = TriforceCount();
18475
18476
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 34 times.
45 if(get_qr(qr_4TRI))
18477 {
18478
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18479 10 Guy=0;
18480 9 }
18481 else
18482 {
18483
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 1 times.
34 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18484 33 Guy=0;
18485 }
18486 }
18487 43 break;
18488 }
18489
18490
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 1186 times.
1293 if(Guy)
18491 {
18492
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1157 times.
1186 if(ffire)
18493 1157 blockpath=true;
18494
18495
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 776 times.
1186 if(currscr<128)
18496 776 sfx(WAV_SCALE);
18497
18498
4/4
✓ Branch 0 taken 459 times.
✓ Branch 1 taken 727 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 355 times.
1186 addguy(120,64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true,guyscr);
18499 1186 Hero.Freeze();
18500 1186 }
18501 1293 }
18502
5/6
✓ Branch 0 taken 32141 times.
✓ Branch 1 taken 1789 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 32070 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1789 times.
33930 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18503 {
18504 71 sfx(WAV_SCALE);
18505 71 addguy(120,62,Guy,-14,false,guyscr);
18506 71 }
18507
18508 35223 loaditem();
18509
18510 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18511 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18512
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 35204 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 15 times.
35223 if(tmpscr->room==r10RUPIES && !getmapflag(mf))
18513 {
18514 //setmapflag();
18515
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 15 times.
165 for(int32_t i=0; i<10; i++)
18516 150 additem(ten_rupies_x[i],ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18517 15 }
18518 35234 }
18519
18520 35242 void loaditem()
18521 {
18522 35242 byte Item = 0;
18523
18524
2/2
✓ Branch 0 taken 34338 times.
✓ Branch 1 taken 904 times.
35242 if(currscr<128)
18525 {
18526 34338 Item=tmpscr->item;
18527
18528
4/4
✓ Branch 0 taken 1579 times.
✓ Branch 1 taken 32759 times.
✓ Branch 2 taken 31313 times.
✓ Branch 3 taken 3025 times.
34338 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
18529 {
18530
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 2966 times.
3025 if(tmpscr->flags8&fSECRETITEM)
18531 59 hasitem=8;
18532
2/2
✓ Branch 0 taken 1157 times.
✓ Branch 1 taken 1809 times.
2966 else if(tmpscr->flags&fITEM)
18533 1157 hasitem=1;
18534
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1745 times.
1809 else if(tmpscr->enemyflags&efCARRYITEM)
18535 64 hasitem=4; // Will be set to 2 by roaming_item
18536 else
18537
2/4
✓ Branch 0 taken 1745 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1745 times.
✗ Branch 3 not taken.
3490 items.add(new item((zfix)tmpscr->itemx,
18538
6/12
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1730 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1745 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1745 times.
✗ Branch 11 not taken.
1745 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
18539
6/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1730 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1730 times.
✗ Branch 9 not taken.
1745 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18540
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 1640 times.
1745 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
18541 1745 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18542 3025 }
18543 34338 }
18544
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 475 times.
904 else if(!(DMaps[currdmap].flags&dmfCAVES))
18545 {
18546
4/6
✓ Branch 0 taken 475 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
491 if((!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr[1].flags9&fBELOWRETURN)) && tmpscr[1].room==rSP_ITEM
18547
4/4
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 147 times.
475 && (currscr==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
18548 {
18549 163 Item=tmpscr[1].catchall;
18550
18551
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 162 times.
163 if(Item)
18552
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
324 items.add(new item((zfix)tmpscr->itemx,
18553
3/12
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 162 times.
✗ Branch 11 not taken.
162 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
18554
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
162 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18555 162 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18556 163 }
18557 475 }
18558 35242 }
18559
18560 957 void never_return(int32_t index)
18561 {
18562
2/2
✓ Branch 0 taken 766 times.
✓ Branch 1 taken 191 times.
957 if(!get_qr(qr_KILLALL))
18563 191 goto doit;
18564
18565
2/2
✓ Branch 0 taken 2292 times.
✓ Branch 1 taken 329 times.
2621 for(int32_t i=0; i<guys.Count(); i++)
18566
4/4
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 1312 times.
✓ Branch 2 taken 543 times.
✓ Branch 3 taken 437 times.
2292 if(((((enemy*)guys.spr(i))->d->flags)&guy_never_return) && i!=index)
18567 {
18568 437 goto dontdoit;
18569 329 }
18570
18571 doit:
18572 520 setmapflag(mNEVERRET);
18573 dontdoit:
18574 957 return;
18575 }
18576
18577 63436 bool slowguy(int32_t id)
18578 {
18579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63436 times.
63436 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18580 {
18581 return false;
18582 }
18583 //return (guysbuf[id].step<100);
18584
2/2
✓ Branch 0 taken 53852 times.
✓ Branch 1 taken 9584 times.
63436 switch(id)
18585 {
18586 case eOCTO1S:
18587 case eOCTO2S:
18588 case eOCTO1F:
18589 case eOCTO2F:
18590 case eLEV1:
18591 case eLEV2:
18592 case eROCK:
18593 case eBOULDER:
18594 9584 return true;
18595 }
18596
18597 53852 return false;
18598 63436 }
18599
18600 82771 bool ok2add(int32_t id)
18601 {
18602
2/4
✓ Branch 0 taken 82771 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 82771 times.
82771 if( ((unsigned)(id&0xFFF)) > MAXGUYS || id <= 0)
18603 {
18604 return false;
18605 }
18606
4/4
✓ Branch 0 taken 829 times.
✓ Branch 1 taken 81942 times.
✓ Branch 2 taken 464 times.
✓ Branch 3 taken 365 times.
82771 if(getmapflag(mNEVERRET) && (guysbuf[id].flags & guy_never_return))
18607 464 return false;
18608
18609
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 81666 times.
✓ Branch 2 taken 376 times.
✓ Branch 3 taken 201 times.
82307 switch(guysbuf[id].family)
18610 {
18611 // I added a special case for shooters because having traps on the same screen
18612 // was preventing them from spawning due to TMPNORET. This means they will
18613 // never stay dead, though, so it may not be the best solution. - Saf
18614 case eePROJECTILE:
18615 376 return true;
18616
18617
18618 case eeDIG:
18619 {
18620
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 75 times.
201 switch(guysbuf[id].attributes[9])
18621 {
18622 case 1:
18623
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 47 times.
126 if(!get_qr(qr_NOTMPNORET))
18624 79 return !getmapflag(mTMPNORET);
18625
18626 47 return true;
18627
18628 75 case 0:
18629 default:
18630 75 return true;
18631 }
18632 }
18633 case eeGANON:
18634 case eeTRAP:
18635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
128 if ((guysbuf[id].family == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
18636
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
64 || (guysbuf[id].family == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
18637 [[fallthrough]];
18638 default:
18639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81666 times.
81666 if (guysbuf[id].flags&guy_ignoretmpnr) return true;
18640 81666 break;
18641 }
18642
18643
2/2
✓ Branch 0 taken 20879 times.
✓ Branch 1 taken 60787 times.
81666 if(!get_qr(qr_NOTMPNORET))
18644 60787 return !getmapflag(mTMPNORET);
18645
18646 20879 return true;
18647 82771 }
18648
18649 1408915 void activate_fireball_statue(int32_t pos)
18650 {
18651
3/4
✓ Branch 0 taken 287785 times.
✓ Branch 1 taken 1121130 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 287785 times.
1408915 if(!(tmpscr->enemyflags&efFIREBALLS) || statueID<0)
18652 {
18653 1121130 return;
18654 }
18655
18656 287785 int32_t cx=-1000, cy=-1000;
18657 287785 int32_t x = (pos&15)<<4;
18658 287785 int32_t y = pos&0xF0;
18659
18660 287785 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
18661
18662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287785 times.
287785 if(!isfixedtogrid(statueID))
18663 {
18664
2/2
✓ Branch 0 taken 1508 times.
✓ Branch 1 taken 286277 times.
287785 if(ctype==cL_STATUE)
18665 {
18666 1508 cx=x+4;
18667 1508 cy=y+7;
18668 1508 }
18669
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 284962 times.
286277 else if(ctype==cR_STATUE)
18670 {
18671 1315 cx=x-8;
18672 1315 cy=y-1;
18673 1315 }
18674
2/2
✓ Branch 0 taken 283749 times.
✓ Branch 1 taken 1213 times.
284962 else if(ctype==cC_STATUE)
18675 {
18676 1213 cx=x;
18677 1213 cy=y;
18678 1213 }
18679 287785 }
18680 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
18681 {
18682 cx=x;
18683 cy=y;
18684 }
18685
18686
2/2
✓ Branch 0 taken 283749 times.
✓ Branch 1 taken 4036 times.
287785 if(cx!=-1000) // No point creating it if this is false
18687 {
18688
2/2
✓ Branch 0 taken 9754 times.
✓ Branch 1 taken 4032 times.
13786 for(int32_t j=0; j<guys.Count(); j++)
18689 {
18690
4/4
✓ Branch 0 taken 1698 times.
✓ Branch 1 taken 8056 times.
✓ Branch 2 taken 1694 times.
✓ Branch 3 taken 4 times.
9754 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
18691 {
18692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
18693 4 return; // No point deleting it. A script might be toying with it in some way.
18694 else
18695 guys.del(j);
18696 }
18697 9750 }
18698
18699 4032 addenemy(cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
18700 4032 }
18701 1408915 }
18702
18703 34921 void activate_fireball_statues()
18704 {
18705
2/2
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 33508 times.
34921 if(!(tmpscr->enemyflags&efFIREBALLS))
18706 {
18707 33508 return;
18708 }
18709
18710
2/2
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 248688 times.
250101 for(int32_t i=0; i<176; i++)
18711 {
18712 248688 activate_fireball_statue(i);
18713 248688 }
18714 34921 }
18715
18716 34921 void load_default_enemies()
18717 {
18718 34921 wallm_load_clk=frame-80;
18719
18720
2/2
✓ Branch 0 taken 33041 times.
✓ Branch 1 taken 1880 times.
34921 if(tmpscr->enemyflags&efZORA)
18721 {
18722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1880 times.
1880 if(zoraID>=0)
18723 1880 addenemy(-16, -16, zoraID, 0);
18724 1880 }
18725
18726
2/2
✓ Branch 0 taken 34743 times.
✓ Branch 1 taken 178 times.
34921 if(tmpscr->enemyflags&efTRAP4)
18727 {
18728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 if(cornerTrapID>=0)
18729 {
18730 178 addenemy(32, 32, cornerTrapID, -14);
18731 178 addenemy(208, 32, cornerTrapID, -14);
18732 178 addenemy(32, 128, cornerTrapID, -14);
18733 178 addenemy(208, 128, cornerTrapID, -14);
18734 178 }
18735 178 }
18736
18737
2/2
✓ Branch 0 taken 384131 times.
✓ Branch 1 taken 34921 times.
419052 for(int32_t y=0; y<176; y+=16)
18738 {
18739
2/2
✓ Branch 0 taken 6146096 times.
✓ Branch 1 taken 384131 times.
6530227 for(int32_t x=0; x<256; x+=16)
18740 {
18741 6146096 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
18742 6146096 int32_t cflag = MAPFLAG(x, y);
18743 6146096 int32_t cflag_i = MAPCOMBOFLAG(x, y);
18744
18745
4/6
✓ Branch 0 taken 6146096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6145790 times.
✓ Branch 3 taken 306 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6145790 times.
6146096 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
18746 {
18747
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 296 times.
306 if(trapLOSHorizontalID>=0)
18748 296 addenemy(x, y, trapLOSHorizontalID, -14);
18749 306 }
18750
4/6
✓ Branch 0 taken 6145790 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6145584 times.
✓ Branch 3 taken 206 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6145584 times.
6145790 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
18751 {
18752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(trapLOSVerticalID>=0)
18753 206 addenemy(x, y, trapLOSVerticalID, -14);
18754 206 }
18755
4/6
✓ Branch 0 taken 6145584 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6145306 times.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6145306 times.
6145584 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
18756 {
18757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(trapLOS4WayID>=0)
18758 {
18759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(addenemy(x, y, trapLOS4WayID, -14))
18760 278 guys.spr(guys.Count()-1)->dummy_int[1]=2;
18761 278 }
18762 278 }
18763
18764
4/6
✓ Branch 0 taken 6145306 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6144907 times.
✓ Branch 3 taken 399 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6144907 times.
6145306 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
18765 {
18766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(trapConstantHorizontalID>=0)
18767 399 addenemy(x, y, trapConstantHorizontalID, -14);
18768 399 }
18769
4/6
✓ Branch 0 taken 6144907 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6144474 times.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6144474 times.
6144907 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
18770 {
18771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if(trapConstantVerticalID>=0)
18772 433 addenemy(x, y, trapConstantVerticalID, -14);
18773 433 }
18774
18775
1/2
✓ Branch 0 taken 6146096 times.
✗ Branch 1 not taken.
6146096 if(ctype==cSPINTILE1)
18776 {
18777 // Awaken spinning tile
18778 awaken_spinning_tile(tmpscr,COMBOPOS(x,y));
18779 }
18780 6146096 }
18781 384131 }
18782
18783
2/2
✓ Branch 0 taken 34865 times.
✓ Branch 1 taken 56 times.
34921 if(tmpscr->enemyflags&efTRAP2)
18784 {
18785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(centerTrapID>=-1)
18786 {
18787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(addenemy(64, 80, centerTrapID, -14))
18788 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18789
18790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(addenemy(176, 80, centerTrapID, -14))
18791 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18792 56 }
18793 56 }
18794
18795
2/2
✓ Branch 0 taken 34838 times.
✓ Branch 1 taken 83 times.
34921 if(tmpscr->enemyflags&efROCKS)
18796 {
18797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(rockID>=0)
18798 {
18799 83 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
18800 83 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
18801 83 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
18802 83 }
18803 83 }
18804
18805 34921 activate_fireball_statues();
18806 34921 }
18807
18808 44584148 void update_slope_combopos(int32_t lyr, int32_t pos)
18809 {
18810
2/4
✓ Branch 0 taken 44584148 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 44584148 times.
44584148 if(unsigned(lyr) > 6 || unsigned(pos) > 175) return;
18811 44584148 mapscr* s = FFCore.tempScreens[lyr];
18812 44584148 newcombo const& cmb = combobuf[s->data[pos]];
18813
18814 44584148 auto id = (176*lyr)+pos;
18815 44584148 auto it = slopes.find(id);
18816
18817 44584148 bool wasSlope = it!=slopes.end();
18818 44584148 bool isSlope = cmb.type == cSLOPE;
18819
18820
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 44584012 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
44584148 if(isSlope && !wasSlope)
18821 {
18822 136 slopes.try_emplace(id, &(s->data[pos]), nullptr, -1, id, pos);
18823 136 }
18824
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44584012 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44584012 else if(wasSlope && !isSlope)
18825 {
18826 slopes.erase(it);
18827 }
18828 44584148 }
18829 35306 void update_slope_comboposes()
18830 {
18831
2/2
✓ Branch 0 taken 247142 times.
✓ Branch 1 taken 35306 times.
282448 for(auto lyr = 0; lyr < 7; ++lyr)
18832 {
18833
2/2
✓ Branch 0 taken 43496992 times.
✓ Branch 1 taken 247142 times.
43744134 for(auto pos = 0; pos < 176; ++pos)
18834 43496992 update_slope_combopos(lyr,pos);
18835 247142 }
18836 35306 }
18837
18838 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
18839 // There's 2 routines because it's unclear if combobuf or tmpscr->data gets modified. -L
18840 1160227 void screen_combo_modify_preroutine(mapscr *s, int32_t pos)
18841 {
18842 1160227 delete_fireball_shooter(s, pos);
18843 1160227 }
18844
18845 //Placeholder in case we need it.
18846 void screen_ffc_modify_preroutine(word index)
18847 {
18848 return;
18849 }
18850
18851 // Everything that must be done after we change a screen's combo to another combo. -L
18852 1160227 void screen_combo_modify_postroutine(mapscr *s, int32_t pos)
18853 {
18854 1160227 s->valid |= mVALID;
18855 1160227 activate_fireball_statue(pos);
18856
18857
2/2
✓ Branch 0 taken 1160133 times.
✓ Branch 1 taken 94 times.
1160227 if(combobuf[s->data[pos]].type==cSPINTILE1)
18858 {
18859 // Awaken spinning tile
18860 94 awaken_spinning_tile(s,pos);
18861 94 }
18862 1160227 int32_t lyr = -1;
18863
2/2
✓ Branch 0 taken 118155 times.
✓ Branch 1 taken 1042072 times.
1160227 if(s == tmpscr) lyr = 0;
18864
2/2
✓ Branch 0 taken 73071 times.
✓ Branch 1 taken 593895 times.
666966 else for(size_t q = 0; q < 6; ++q)
18865 {
18866
2/2
✓ Branch 0 taken 45084 times.
✓ Branch 1 taken 548811 times.
593895 if(s == tmpscr2+q)
18867 {
18868 45084 lyr = q+1;
18869 45084 break;
18870 }
18871 548811 }
18872
2/2
✓ Branch 0 taken 73071 times.
✓ Branch 1 taken 1087156 times.
1160227 if(lyr > -1)
18873 1087156 update_slope_combopos(lyr,pos);
18874 1160227 }
18875
18876 5324310 void screen_ffc_modify_postroutine(word index)
18877 {
18878 5324310 ffcdata& ff = tmpscr->ffcs[index];
18879 5324310 newcombo const& cmb = combobuf[ff.data];
18880
18881 5324310 auto id = (176*7)+int32_t(index);
18882 5324310 auto it = slopes.find(id);
18883
18884 5324310 bool wasSlope = it!=slopes.end();
18885
1/2
✓ Branch 0 taken 5324310 times.
✗ Branch 1 not taken.
5324310 bool isSlope = cmb.type == cSLOPE && !(ff.flags&ffc_changer);
18886
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5324310 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5324310 if(isSlope && !wasSlope)
18887 {
18888 slopes.try_emplace(id, nullptr, &ff, index, id);
18889 }
18890
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5324310 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5324310 else if(wasSlope && !isSlope)
18891 {
18892 slopes.erase(it);
18893 }
18894
18895 5324310 tmpscr->ffcCountMarkDirty();
18896 5324310 }
18897
18898 4404 void screen_combo_modify_pre(int32_t cid)
18899 {
18900
2/2
✓ Branch 0 taken 30828 times.
✓ Branch 1 taken 4404 times.
35232 for(auto lyr = 0; lyr < 7; ++lyr)
18901 {
18902 30828 mapscr* t = FFCore.tempScreens[lyr];
18903
2/2
✓ Branch 0 taken 5425728 times.
✓ Branch 1 taken 30828 times.
5456556 for(int32_t i = 0; i < 176; i++)
18904 {
18905
2/2
✓ Branch 0 taken 5419127 times.
✓ Branch 1 taken 6601 times.
5425728 if(t->data[i] == cid)
18906 {
18907 6601 screen_combo_modify_preroutine(t,i);
18908 6601 }
18909 5425728 }
18910 30828 }
18911 4404 }
18912 4404 void screen_combo_modify_post(int32_t cid)
18913 {
18914
2/2
✓ Branch 0 taken 30828 times.
✓ Branch 1 taken 4404 times.
35232 for(auto lyr = 0; lyr < 7; ++lyr)
18915 {
18916 30828 mapscr* t = FFCore.tempScreens[lyr];
18917
2/2
✓ Branch 0 taken 5425728 times.
✓ Branch 1 taken 30828 times.
5456556 for(int32_t i = 0; i < 176; i++)
18918 {
18919
2/2
✓ Branch 0 taken 5419127 times.
✓ Branch 1 taken 6601 times.
5425728 if(t->data[i] == cid)
18920 {
18921 6601 screen_combo_modify_postroutine(t,i);
18922 6601 }
18923 5425728 }
18924 30828 }
18925 4404 int c = tmpscr->numFFC();
18926
2/2
✓ Branch 0 taken 139510 times.
✓ Branch 1 taken 4404 times.
143914 for(word ind = 0; ind < c; ++ind)
18927 {
18928
2/2
✓ Branch 0 taken 139452 times.
✓ Branch 1 taken 58 times.
139510 if(tmpscr->ffcs[ind].data == cid)
18929 58 screen_ffc_modify_postroutine(ind);
18930 139510 }
18931 4404 }
18932
18933 94 void awaken_spinning_tile(mapscr *s, int32_t pos)
18934 {
18935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 addenemy((pos&15)<<4,pos&0xF0,(s->cset[pos]<<12)+eSPINTILE1,combobuf[s->data[pos]].o_tile+zc_max(1,combobuf[s->data[pos]].frames));
18936 94 }
18937
18938
18939 // It stands for next_side_pos
18940 11436 void nsp(bool random)
18941 // moves sle_x and sle_y to the next position
18942 {
18943
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 8175 times.
11436 if(random)
18944 {
18945
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
18946 {
18947 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
18948 1634 sle_y = (zc_oldrand()%10)*16;
18949 1634 }
18950 else
18951 {
18952 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
18953 1627 sle_x = (zc_oldrand()%15)*16;
18954 }
18955
18956 3261 return;
18957 }
18958
18959
2/2
✓ Branch 0 taken 6151 times.
✓ Branch 1 taken 2024 times.
8175 if(sle_x==0)
18960 {
18961
2/2
✓ Branch 0 taken 1845 times.
✓ Branch 1 taken 179 times.
2024 if(sle_y<160)
18962 1845 sle_y+=16;
18963 else
18964 179 sle_x+=16;
18965 2024 }
18966
2/2
✓ Branch 0 taken 2581 times.
✓ Branch 1 taken 3570 times.
6151 else if(sle_y==160)
18967 {
18968
2/2
✓ Branch 0 taken 2416 times.
✓ Branch 1 taken 165 times.
2581 if(sle_x<240)
18969 2416 sle_x+=16;
18970 else
18971 165 sle_y-=16;
18972 2581 }
18973
2/2
✓ Branch 0 taken 1550 times.
✓ Branch 1 taken 2020 times.
3570 else if(sle_x==240)
18974 {
18975
2/2
✓ Branch 0 taken 1402 times.
✓ Branch 1 taken 148 times.
1550 if(sle_y>0)
18976 1402 sle_y-=16;
18977 else
18978 148 sle_x-=16;
18979 1550 }
18980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2020 times.
2020 else if(sle_y==0)
18981 {
18982
1/2
✓ Branch 0 taken 2020 times.
✗ Branch 1 not taken.
2020 if(sle_x>0)
18983 2020 sle_x-=16;
18984 else
18985 sle_y+=16;
18986 2020 }
18987 11436 }
18988
18989 2426 int32_t next_side_pos(bool random)
18990 // moves sle_x and sle_y to the next available position
18991 // returns the direction the enemy should face
18992 {
18993 bool blocked;
18994 2426 int32_t c=0;
18995
18996 2426 do
18997 {
18998
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 11305 times.
11436 nsp(c>35 ? false : random);
18999
4/4
✓ Branch 0 taken 2444 times.
✓ Branch 1 taken 8992 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 2425 times.
13861 blocked = _walkflag(sle_x,sle_y,2) || _walkflag(sle_x,sle_y+8,2) ||
19000
1/2
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
2425 (combo_class_buf[COMBOTYPE(sle_x,sle_y)].block_enemies ||
19001
2/4
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2425 times.
✗ Branch 3 not taken.
2425 MAPFLAG(sle_x,sle_y) == mfNOENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOENEMY ||
19002
2/4
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2425 times.
2425 MAPFLAG(sle_x,sle_y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOGROUNDENEMY ||
19003 2425 iswaterex(MAPCOMBO(sle_x,sle_y), currmap, currscr, -1, sle_x, sle_y, true));
19004
19005
2/2
✓ Branch 0 taken 11435 times.
✓ Branch 1 taken 1 times.
11436 if(++c>50)
19006 1 return -1;
19007
2/2
✓ Branch 0 taken 9010 times.
✓ Branch 1 taken 2425 times.
11435 }
19008 11435 while(blocked);
19009
19010 2425 int32_t dir=0;
19011
19012
2/2
✓ Branch 0 taken 1690 times.
✓ Branch 1 taken 735 times.
2425 if(sle_x==0) dir=right;
19013
19014
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 569 times.
2425 if(sle_y==0) dir=down;
19015
19016
2/2
✓ Branch 0 taken 1719 times.
✓ Branch 1 taken 706 times.
2425 if(sle_x==240) dir=left;
19017
19018
1/2
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
2425 if(sle_y==168) dir=up;
19019
19020 2425 return dir;
19021 2426 }
19022
19023 bool can_side_load(int32_t id)
19024 {
19025 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
19026 {
19027 return false;
19028 }
19029 switch(guysbuf[id].family) //id&0x0FFF)
19030 {
19031 //case eTEK1:
19032 //case eTEK2:
19033 //case eTEK3:
19034 //case eLEV1:
19035 //case eLEV2:
19036 //case eLEV3:
19037 //case eRAQUAM:
19038 //case eLAQUAM:
19039 //case eDODONGO:
19040 //case eMANHAN:
19041 //case eGLEEOK1:
19042 //case eGLEEOK2:
19043 //case eGLEEOK3:
19044 //case eGLEEOK4:
19045 //case eDIG1:
19046 //case eDIG3:
19047 //case eGOHMA1:
19048 //case eGOHMA2:
19049 //case eCENT1:
19050 //case eCENT2:
19051 //case ePATRA1:
19052 //case ePATRA2:
19053 //case eGANON:
19054 //case eMANHAN2:
19055 //case eCEILINGM: later
19056 //case eFLOORM: later
19057 //case ePATRABS:
19058 //case ePATRAL2:
19059 //case ePATRAL3:
19060 //case eGLEEOK1F:
19061 //case eGLEEOK2F:
19062 //case eGLEEOK3F:
19063 //case eGLEEOK4F:
19064 //case eDODONGOBS:
19065 //case eDODONGOF:
19066 //case eGOHMA3:
19067 //case eGOHMA4:
19068 //case eSHOOTMAGIC:
19069 //case eSHOOTROCK:
19070 //case eSHOOTSPEAR:
19071 //case eSHOOTSWORD:
19072 //case eSHOOTFLAME:
19073 //case eSHOOTFLAME2:
19074 //case eSHOOTFBALL:
19075 case eeTEK:
19076 case eeLEV:
19077 case eeAQUA:
19078 case eeDONGO:
19079 case eeMANHAN:
19080 case eeGLEEOK:
19081 case eeDIG:
19082 case eeGHOMA:
19083 case eeLANM:
19084 case eePATRA:
19085 case eeGANON:
19086 case eePROJECTILE:
19087 return false;
19088 break;
19089 }
19090
19091 return true;
19092 }
19093
19094 static bool script_sle = false;
19095 static int32_t sle_pattern = 0;
19096 void script_side_load_enemies()
19097 {
19098 if(script_sle || sle_clk) return;
19099 sle_cnt = 0;
19100 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19101 ++sle_cnt;
19102 script_sle = true;
19103 sle_pattern = tmpscr->pattern;
19104 sle_clk = 0;
19105 }
19106
19107 54442 void side_load_enemies()
19108 {
19109
3/4
✓ Branch 0 taken 54442 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53760 times.
✓ Branch 3 taken 682 times.
54442 if(!script_sle && sle_clk==0)
19110 {
19111 682 sle_pattern = tmpscr->pattern;
19112 682 sle_cnt = 0;
19113 682 int32_t guycnt = 0;
19114 682 int16_t s = (currmap<<7)+currscr;
19115 682 bool beenhere=false;
19116 682 bool reload=true;
19117 682 bool unbeatablereload = true;
19118
19119 682 load_default_enemies();
19120
19121
2/2
✓ Branch 0 taken 4092 times.
✓ Branch 1 taken 682 times.
4774 for(int32_t i=0; i<6; i++)
19122
2/2
✓ Branch 0 taken 3889 times.
✓ Branch 1 taken 203 times.
4295 if(visited[i]==s)
19123 203 beenhere=true;
19124
19125
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 479 times.
682 if(!beenhere)
19126 {
19127 479 visited[vhead]=s;
19128 479 vhead = (vhead+1)%6;
19129 479 }
19130
2/2
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 42 times.
203 else if(game->guys[s]==0)
19131 {
19132 42 sle_cnt=0;
19133 42 reload=false;
19134 42 }
19135
19136
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 640 times.
682 if(reload)
19137 {
19138 640 sle_cnt = game->guys[s];
19139
19140
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 640 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 220 times.
640 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
19141 640 || sle_cnt==0)
19142 {
19143
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1267 times.
✓ Branch 2 taken 1050 times.
✓ Branch 3 taken 220 times.
1270 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19144 1050 ++sle_cnt;
19145 220 }
19146
3/4
✓ Branch 0 taken 479 times.
✓ Branch 1 taken 161 times.
✓ Branch 2 taken 479 times.
✗ Branch 3 not taken.
640 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19147 {
19148 for(int32_t i = 0; i<sle_cnt && tmpscr->enemy[i]>0; i++)
19149 {
19150 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesnt_count))
19151 {
19152 unbeatablereload = false;
19153 }
19154 }
19155 if (unbeatablereload)
19156 {
19157 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19158 {
19159 ++sle_cnt;
19160 }
19161 }
19162 }
19163 640 }
19164
19165
3/4
✓ Branch 0 taken 651 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 651 times.
682 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN))
19166 {
19167 31 sle_cnt = 0;
19168
19169
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 31 times.
139 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19170 108 ++sle_cnt;
19171 31 }
19172
19173
2/2
✓ Branch 0 taken 2442 times.
✓ Branch 1 taken 682 times.
3124 for(int32_t i=0; i<sle_cnt; i++)
19174 2442 ++guycnt;
19175
19176 682 game->guys[s] = guycnt;
19177 682 }
19178
19179
2/2
✓ Branch 0 taken 52016 times.
✓ Branch 1 taken 2426 times.
54442 if((++sle_clk+8)%24 == 0)
19180 {
19181 2426 int32_t dir = next_side_pos(sle_pattern==pSIDESR);
19182
19183
4/4
✓ Branch 0 taken 2425 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 232 times.
✓ Branch 3 taken 2193 times.
2426 if(dir==-1 || tooclose(sle_x,sle_y,32))
19184 {
19185 233 return;
19186 }
19187
19188 2193 int32_t enemy_slot=guys.Count();
19189
19190
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2193 times.
2193 while(sle_cnt > 0 && !ok2add(tmpscr->enemy[sle_cnt-1]))
19191 sle_cnt--;
19192
19193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
2193 if(sle_cnt > 0)
19194 {
19195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
2193 if(addenemy(sle_x,sle_y,tmpscr->enemy[--sle_cnt],0))
19196 {
19197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
2193 if (((enemy*)guys.spr(enemy_slot))->family != eeTEK)
19198 {
19199 2193 guys.spr(enemy_slot)->dir = dir;
19200 2193 }
19201
1/2
✓ Branch 0 taken 2193 times.
✗ Branch 1 not taken.
2193 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19202 {
19203 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19204 {
19205 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
19206 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
19207 }
19208 }
19209 2193 }
19210 2193 }
19211 2193 }
19212
19213
2/2
✓ Branch 0 taken 53631 times.
✓ Branch 1 taken 578 times.
54209 if(sle_cnt<=0)
19214 {
19215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
578 if(script_sle)
19216 script_sle = false;
19217 578 else loaded_enemies=true;
19218 578 sle_clk = 0;
19219 578 }
19220 54442 }
19221
19222 1208109 bool is_starting_pos(int32_t i, int32_t x, int32_t y, int32_t t)
19223 {
19224
19225
4/4
✓ Branch 0 taken 1105225 times.
✓ Branch 1 taken 102884 times.
✓ Branch 2 taken 102884 times.
✓ Branch 3 taken 1208109 times.
1208109 if(tmpscr->enemy[i]<1||tmpscr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
19226 {
19227 205768 return false; //never 0, never OoB.
19228 }
19229 // No corner enemies
19230
6/6
✓ Branch 0 taken 1042349 times.
✓ Branch 1 taken 165760 times.
✓ Branch 2 taken 40016 times.
✓ Branch 3 taken 1082365 times.
✓ Branch 4 taken 114320 times.
✓ Branch 5 taken 91456 times.
1208109 if((x==0 || x==240) && (y==0 || y==160))
19231
19232 205776 return false;
19233
19234 //Is a no spawn combo...
19235
4/4
✓ Branch 0 taken 1082353 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1082349 times.
1082365 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
19236 16 return false;
19237
19238 // No enemies in dungeon walls
19239
10/10
✓ Branch 0 taken 655073 times.
✓ Branch 1 taken 427276 times.
✓ Branch 2 taken 582513 times.
✓ Branch 3 taken 72560 times.
✓ Branch 4 taken 509953 times.
✓ Branch 5 taken 72560 times.
✓ Branch 6 taken 422881 times.
✓ Branch 7 taken 87072 times.
✓ Branch 8 taken 87072 times.
✓ Branch 9 taken 335809 times.
1082349 if(isdungeon() && (x<32 || x>=224 || y<32 || y>=144))
19240 319264 return false;
19241
19242 // Too close
19243
4/4
✓ Branch 0 taken 74233 times.
✓ Branch 1 taken 688852 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 74132 times.
763085 if(tooclose(x,y,40) && t<11)
19244 74132 return false;
19245
19246 // Can't fly onto it?
19247
4/4
✓ Branch 0 taken 122271 times.
✓ Branch 1 taken 566682 times.
✓ Branch 2 taken 35960 times.
✓ Branch 3 taken 17932 times.
742845 if(isflier(tmpscr->enemy[i])&&
19248
2/2
✓ Branch 0 taken 121881 times.
✓ Branch 1 taken 390 times.
122271 (flyerblocked(x+8,y+8,spw_floater,guysbuf[tmpscr->enemy[i]])||
19249
2/2
✓ Branch 0 taken 53892 times.
✓ Branch 1 taken 67989 times.
121881 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
19250 18322 return false;
19251
19252 // Can't jump onto it?
19253 if
19254 (
19255
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 86588 times.
757223 guysbuf[tmpscr->enemy[i]].family==eeTEK
19256
19257
2/2
✓ Branch 0 taken 86606 times.
✓ Branch 1 taken 584025 times.
670631 &&
19258 (
19259
2/2
✓ Branch 0 taken 86599 times.
✓ Branch 1 taken 7 times.
86606 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
19260
2/2
✓ Branch 0 taken 86598 times.
✓ Branch 1 taken 1 times.
86599 COMBOTYPE(x+8,y+8)==cNOENEMY||
19261
1/2
✓ Branch 0 taken 86598 times.
✗ Branch 1 not taken.
86598 ispitfall(x+8,y+8)||
19262
2/2
✓ Branch 0 taken 86592 times.
✓ Branch 1 taken 6 times.
86598 MAPFLAG(x+8,y+8)==mfNOENEMY||
19263 86592 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
19264 )
19265 )
19266 {
19267 18 return false;
19268 }
19269
19270 // Other off-limit combos
19271
6/6
✓ Branch 0 taken 566668 times.
✓ Branch 1 taken 103945 times.
✓ Branch 2 taken 480080 times.
✓ Branch 3 taken 86588 times.
✓ Branch 4 taken 263614 times.
✓ Branch 5 taken 216466 times.
1150693 if((!isflier(tmpscr->enemy[i])&& guysbuf[tmpscr->enemy[i]].family!=eeTEK &&
19272
2/2
✓ Branch 0 taken 268956 times.
✓ Branch 1 taken 211124 times.
480080 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[tmpscr->enemy[i]]))) &&
19273 480080 guysbuf[tmpscr->enemy[i]].family!=eeZORA)
19274 216466 return false;
19275
19276 // Don't ever generate enemies on these combos!
19277
4/4
✓ Branch 0 taken 453851 times.
✓ Branch 1 taken 296 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 453857 times.
454147 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19278 302 return false;
19279
19280 //BS Dodongos need at least 2 spaces.
19281
4/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 452818 times.
✓ Branch 2 taken 1014 times.
✓ Branch 3 taken 25 times.
453857 if((guysbuf[tmpscr->enemy[i]].family==eeDONGO)&&(guysbuf[tmpscr->enemy[i]].attributes[9] ==1))
19282 {
19283
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
25 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19284
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 ((x>224)||_walkflag(x+16,y+8, 2))&&
19285
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 ((y<16) ||_walkflag(x, y-8, 2))&&
19286 ((y>144)||_walkflag(x, y+24,2)))
19287 {
19288 return false;
19289 }
19290 19 }
19291
19292 453851 return true;
19293 1105225 }
19294
19295 159458 bool is_ceiling_pattern(int32_t i)
19296 {
19297
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 159438 times.
159458 return (i==pCEILING || i==pCEILINGR);
19298 }
19299
19300 5716 int32_t placeenemy(int32_t i)
19301 {
19302 5716 std::map<int32_t, int32_t> freeposcache;
19303 5716 int32_t frees = 0;
19304
19305
2/2
✓ Branch 0 taken 62876 times.
✓ Branch 1 taken 5716 times.
68592 for(int32_t y=0; y<176; y+=16)
19306 {
19307
2/2
✓ Branch 0 taken 1006016 times.
✓ Branch 1 taken 62876 times.
1068892 for(int32_t x=0; x<256; x+=16)
19308 {
19309
3/4
✓ Branch 0 taken 1006016 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 396120 times.
✓ Branch 3 taken 609896 times.
1006016 if(is_starting_pos(i,x,y,0))
19310 {
19311
1/2
✓ Branch 0 taken 396120 times.
✗ Branch 1 not taken.
396120 freeposcache[frees++] = (y&0xF0)+(x>>4);
19312 396120 }
19313 1006016 }
19314 62876 }
19315
19316
2/2
✓ Branch 0 taken 5705 times.
✓ Branch 1 taken 11 times.
5716 if(frees > 0)
19317
2/4
✓ Branch 0 taken 5705 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5705 times.
✗ Branch 3 not taken.
5705 return freeposcache[zc_oldrand()%frees];
19318
19319 11 return -1;
19320 5716 }
19321
19322 80540 void spawnEnemy(int& pos, int& clk, int& x, int& y, int& fastguys, int& i, int& guycnt, int& loadcnt)
19323 {
19324 80540 bool placed=false;
19325 80540 int32_t t=-1;
19326
19327 // First: enemy combo flags
19328
2/2
✓ Branch 0 taken 800180 times.
✓ Branch 1 taken 63447 times.
863627 for(int32_t sy=0; sy<176; sy+=16)
19329 {
19330
2/2
✓ Branch 0 taken 12675627 times.
✓ Branch 1 taken 783087 times.
13458714 for(int32_t sx=0; sx<256; sx+=16)
19331 {
19332 12675627 int32_t cflag = MAPFLAG(sx, sy);
19333 12675627 int32_t cflag_i = MAPCOMBOFLAG(sx, sy);
19334
19335
2/4
✓ Branch 0 taken 12675627 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12675627 times.
✗ Branch 3 not taken.
12675627 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19336 {
19337 if(!ok2add(tmpscr->enemy[i]))
19338 {
19339 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19340 }
19341 else
19342 {
19343 addenemy(sx,
19344 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19345 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19346
19347 ++guycnt;
19348
19349 placed=true;
19350 goto placed_enemy;
19351 }
19352 }
19353
19354
4/4
✓ Branch 0 taken 12658485 times.
✓ Branch 1 taken 17142 times.
✓ Branch 2 taken 12658485 times.
✓ Branch 3 taken 17142 times.
12675627 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19355 {
19356
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 17093 times.
17142 if(!ok2add(tmpscr->enemy[i]))
19357 {
19358
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
49 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19359 49 }
19360 else
19361 {
19362 34186 addenemy(sx,
19363
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17092 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17093 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19364
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17092 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
17093 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19365
19366 17093 ++guycnt;
19367
19368 17093 placed=true;
19369 17093 goto placed_enemy;
19370 }
19371 49 }
19372 12658534 }
19373 783087 }
19374
19375 // Next: enemy pattern
19376
6/8
✓ Branch 0 taken 4939 times.
✓ Branch 1 taken 58508 times.
✓ Branch 2 taken 57952 times.
✓ Branch 3 taken 5495 times.
✓ Branch 4 taken 57952 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 57952 times.
63447 if((tmpscr->pattern==pRANDOM || tmpscr->pattern==pCEILING) && !(isSideViewGravity()) && ((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS)))
19377 {
19378 57952 do
19379 {
19380
19381 // NES positions
19382 99430 pos%=9;
19383 99430 x=stx[loadside][pos];
19384 99430 y=sty[loadside][pos];
19385 99430 ++pos;
19386 99430 ++t;
19387
2/2
✓ Branch 0 taken 41478 times.
✓ Branch 1 taken 57952 times.
157382 }
19388
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 99209 times.
99430 while((t< 20) && !is_starting_pos(i,x,y,t));
19389 57952 }
19390
19391
4/4
✓ Branch 0 taken 57952 times.
✓ Branch 1 taken 5495 times.
✓ Branch 2 taken 221 times.
✓ Branch 3 taken 57731 times.
63447 if(t<0 || t >= 20) // above enemy pattern failed
19392 {
19393 // Final chance: find a random position anywhere onscreen
19394 5716 int32_t randpos = placeenemy(i);
19395
19396
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5705 times.
5716 if(randpos>-1)
19397 {
19398 5705 x=(randpos&15)<<4;
19399 5705 y= randpos&0xF0;
19400 5705 }
19401 else // All opportunities failed - abort
19402 {
19403 11 return;
19404 }
19405 5705 }
19406
19407 {
19408 63436 int32_t c=0;
19409 63436 c=clk;
19410
19411
2/2
✓ Branch 0 taken 9584 times.
✓ Branch 1 taken 53852 times.
63436 if(!slowguy(tmpscr->enemy[i]))
19412 53852 ++fastguys;
19413
2/2
✓ Branch 0 taken 1586 times.
✓ Branch 1 taken 7998 times.
9584 else if(fastguys>0)
19414 1586 c=-15*(i-fastguys+2);
19415 else
19416 7998 c=-15*(i+1);
19417
19418
4/6
✓ Branch 0 taken 28859 times.
✓ Branch 1 taken 34577 times.
✓ Branch 2 taken 28859 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 28859 times.
63436 if(BSZ&&((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19419 {
19420 // Special case for blue leevers
19421
4/4
✓ Branch 0 taken 1894 times.
✓ Branch 1 taken 26965 times.
✓ Branch 2 taken 761 times.
✓ Branch 3 taken 1133 times.
28859 if(guysbuf[tmpscr->enemy[i]].family==eeLEV && guysbuf[tmpscr->enemy[i]].attributes[0]==1)
19422 761 c=-15*(i+1);
19423 else
19424 28098 c=-15;
19425 28859 }
19426
19427
2/2
✓ Branch 0 taken 62636 times.
✓ Branch 1 taken 800 times.
63436 if(!ok2add(tmpscr->enemy[i]))
19428 {
19429
4/6
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 670 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 130 times.
800 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19430 800 }
19431 else
19432 {
19433
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62636 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62636 if(((tmpscr->enemy[i]>0||tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19434 {
19435
3/4
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 62506 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
125272 addenemy(x,(is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19436
3/4
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 62506 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 130 times.
62636 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],c);
19437
19438 62636 ++guycnt;
19439 62636 }
19440 }
19441
19442 63436 placed=true;
19443 63436 } // if(t < 20)
19444
19445 placed_enemy:
19446
19447 // I don't like this, but it seems to work...
19448 static bool foundCarrier;
19449
19450
2/2
✓ Branch 0 taken 59157 times.
✓ Branch 1 taken 21372 times.
80529 if(i==0)
19451 21372 foundCarrier=false;
19452
19453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80529 times.
80529 if(placed)
19454 {
19455
4/4
✓ Branch 0 taken 21372 times.
✓ Branch 1 taken 59157 times.
✓ Branch 2 taken 21203 times.
✓ Branch 3 taken 169 times.
80529 if(i==0 && tmpscr->enemyflags&efLEADER)
19456 {
19457 169 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19458
19459
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 7 times.
169 if(index!=-1)
19460 {
19461 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19462
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 if ((((enemy*)guys.spr(index))->family == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER)) index = guys.idNth(tmpscr->enemy[i], 2, 0xFFF);
19463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
162 if(index!=-1)
19464 {
19465 162 ((enemy*)guys.spr(index))->leader = true;
19466 162 }
19467 162 }
19468 169 }
19469
19470
4/4
✓ Branch 0 taken 80306 times.
✓ Branch 1 taken 223 times.
✓ Branch 2 taken 80242 times.
✓ Branch 3 taken 64 times.
80529 if(!foundCarrier && hasitem&(4|2))
19471 {
19472 64 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19473
19474
2/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
64 if(index!=-1 && (((enemy*)guys.spr(index))->flags&guy_doesnt_count)==0)
19475 {
19476 64 ((enemy*)guys.spr(index))->itemguy = true;
19477 64 foundCarrier=true;
19478 64 }
19479 64 }
19480 80529 }
19481 80540 }
19482
19483 bool scriptloadenemies()
19484 {
19485 loaded_enemies = true;
19486 if(script_sle || sle_clk) return false;
19487 if(tmpscr->pattern==pNOSPAWN) return false;
19488
19489 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
19490 {
19491 script_side_load_enemies();
19492 return true;
19493 }
19494
19495 int32_t pos=zc_oldrand()%9;
19496 int32_t clk=-15,x=0,y=0,fastguys=0;
19497 int32_t i=0,guycnt=0;
19498 int32_t loadcnt = 10;
19499
19500 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
19501 {
19502 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19503 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19504 if (guys.Count() > preguycount)
19505 {
19506 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19507 {
19508 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19509 {
19510 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19511 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19512 }
19513 }
19514 }
19515 --clk;
19516 }
19517 return true;
19518 }
19519
19520 14113885 void loadenemies()
19521 {
19522
3/4
✓ Branch 0 taken 14113885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53760 times.
✓ Branch 3 taken 14060125 times.
14113885 if(script_sle || sle_clk)
19523 {
19524 53760 side_load_enemies();
19525 53760 return;
19526 }
19527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14060125 times.
14060125 if(tmpscr->pattern==pNOSPAWN) return;
19528
2/2
✓ Branch 0 taken 14025114 times.
✓ Branch 1 taken 35011 times.
14060125 if(loaded_enemies)
19529 14025114 return;
19530
19531 // check if it's the dungeon boss and it has been beaten before
19532
4/4
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 34652 times.
✓ Branch 2 taken 269 times.
✓ Branch 3 taken 90 times.
35011 if(tmpscr->enemyflags&efBOSS && game->lvlitems[dlevel]&liBOSS)
19533 {
19534 90 loaded_enemies = true;
19535 90 return;
19536 }
19537
19538
4/4
✓ Branch 0 taken 34480 times.
✓ Branch 1 taken 441 times.
✓ Branch 2 taken 241 times.
✓ Branch 3 taken 34239 times.
34921 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
19539 {
19540 682 side_load_enemies();
19541 682 return;
19542 }
19543
19544 34239 loaded_enemies=true;
19545
19546 // do enemies that are always loaded
19547 34239 load_default_enemies();
19548
19549 // dungeon basements
19550
19551 static byte dngn_enemy_x[4] = {32,96,144,208};
19552
19553
2/2
✓ Branch 0 taken 904 times.
✓ Branch 1 taken 33335 times.
34239 if(currscr>=128)
19554 {
19555
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 475 times.
904 if(DMaps[currdmap].flags&dmfCAVES) return;
19556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if ( DMaps[currdmap].flags&dmfNEWCELLARENEMIES )
19557 {
19558 for(int32_t i=0; i<10; i++)
19559 {
19560 if ( tmpscr->enemy[i] )
19561 {
19562 int32_t preguycount = guys.Count();
19563 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i],-14-i);
19564 if (guys.Count() > preguycount)
19565 {
19566 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19567 {
19568 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19569 {
19570 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19571 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19572 }
19573 }
19574 }
19575 }
19576 }
19577 }
19578 else
19579 {
19580
2/2
✓ Branch 0 taken 1900 times.
✓ Branch 1 taken 475 times.
2375 for(int32_t i=0; i<4; i++)
19581 {
19582 1900 int32_t preguycount = guys.Count();
19583
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 856 times.
1900 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i]?tmpscr->enemy[i]:(int32_t)eKEESE1,-14-i);
19584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1900 times.
1900 if (guys.Count() > preguycount)
19585 {
19586
2/2
✓ Branch 0 taken 1896 times.
✓ Branch 1 taken 4 times.
1900 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19587 {
19588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19589 {
19590 4 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19591 4 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19592 4 }
19593 4 }
19594 1900 }
19595 1900 }
19596 }
19597 475 return;
19598 }
19599
19600 // check if it's been long enough to reload all enemies
19601
19602 33335 int32_t loadcnt = 10;
19603 33335 int16_t s = (currmap<<7)+currscr;
19604 33335 bool beenhere = false;
19605 33335 bool reload = true;
19606 33335 bool unbeatablereload = true;
19607
19608
2/2
✓ Branch 0 taken 200010 times.
✓ Branch 1 taken 33335 times.
233345 for(int32_t i=0; i<6; i++)
19609
2/2
✓ Branch 0 taken 190844 times.
✓ Branch 1 taken 9166 times.
209176 if(visited[i]==s)
19610 9166 beenhere = true;
19611
19612
2/2
✓ Branch 0 taken 9166 times.
✓ Branch 1 taken 24169 times.
33335 if(!beenhere) //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
19613 {
19614 24169 visited[vhead]=s; //If not, it adds it to the array,
19615 24169 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
19616 24169 }
19617
2/2
✓ Branch 0 taken 4611 times.
✓ Branch 1 taken 4555 times.
9166 else if(game->guys[s]==0) //Then, if you have been here, and the number of enemies left on the screen is 0,
19618 {
19619 4555 loadcnt = 0; //It will tell it not to load any enemies,
19620 4555 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
19621 4555 }
19622
19623
2/2
✓ Branch 0 taken 4555 times.
✓ Branch 1 taken 28780 times.
33335 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
19624 {
19625 28780 loadcnt = game->guys[s]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
19626
19627
2/4
✓ Branch 0 taken 10143 times.
✓ Branch 1 taken 18637 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
28780 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
19628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10143 times.
10143 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
19629 18637 loadcnt = 10; //That means all enemies need to be respawned.
19630
3/4
✓ Branch 0 taken 24169 times.
✓ Branch 1 taken 4611 times.
✓ Branch 2 taken 24169 times.
✗ Branch 3 not taken.
28780 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19631 {
19632 for(int32_t i = 0; i<loadcnt && tmpscr->enemy[i]>0; i++)
19633 {
19634 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesnt_count))
19635 {
19636 unbeatablereload = false;
19637 }
19638 }
19639 if (unbeatablereload)
19640 {
19641 loadcnt = 10;
19642 }
19643 }
19644 28780 }
19645
19646
4/4
✓ Branch 0 taken 31876 times.
✓ Branch 1 taken 1459 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 31689 times.
33335 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
19647 1646 loadcnt = 10; //All enemies also need to be respawned.
19648
19649 33335 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
19650 33335 int32_t clk=-15,x=0,y=0,fastguys=0; //clk being negative means the enemy is in its spawn poof.
19651 33335 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
19652
19653
4/4
✓ Branch 0 taken 14555 times.
✓ Branch 1 taken 99320 times.
✓ Branch 2 taken 80540 times.
✓ Branch 3 taken 33335 times.
113875 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
19654 {
19655 80540 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19656 80540 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19657
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 79729 times.
80540 if (guys.Count() > preguycount)
19658 {
19659
2/2
✓ Branch 0 taken 77382 times.
✓ Branch 1 taken 2347 times.
79729 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19660 {
19661
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2343 times.
2347 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19662 {
19663 2343 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19664 2343 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19665 2343 }
19666 2347 }
19667 79729 }
19668
19669 80540 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
19670 80540 }
19671
19672 33335 game->guys[s] = guycnt;
19673 //} //if(true)
19674 14113885 }
19675 233 void moneysign()
19676 {
19677 233 additem(48,108,iRupy,ipDUMMY);
19678 233 set_clip_state(pricesdisplaybuf, 0);
19679 233 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
19680 233 }
19681
19682 3267 void putprices(bool sign)
19683 {
19684
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 3238 times.
3267 if(fadeclk > 0) return;
19685
19686 3238 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
19687 3238 int32_t step=32;
19688 3238 int32_t x=80;
19689
19690
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 2957 times.
3238 if(prices[2]==0)
19691 {
19692 2957 step<<=1;
19693
19694
2/2
✓ Branch 0 taken 2925 times.
✓ Branch 1 taken 32 times.
2957 if(prices[1]==0)
19695 {
19696 2925 x=112;
19697 2925 }
19698 2957 }
19699
19700
2/2
✓ Branch 0 taken 3238 times.
✓ Branch 1 taken 9714 times.
12952 for(int32_t i=0; i<3; i++)
19701 {
19702 // Kind of stupid, but it works: 100000 is used to indicate that an item
19703 // has a price of zero rather than there being no item.
19704 // 100000 isn't a valid price, so this doesn't cause problems.
19705
3/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 8675 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1039 times.
9714 if(prices[i]!=0 && prices[i]<100000)
19706 {
19707 char buf[8];
19708 1039 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
19709
19710 1039 int32_t l=(int32_t)strlen(buf);
19711 1039 set_clip_state(pricesdisplaybuf, 0);
19712
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1012 times.
1039 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
19713 1039 }
19714
19715 9714 x+=step;
19716 9714 }
19717 3267 }
19718
19719 // Setting up special rooms
19720 // Also called when the Letter is used successfully.
19721 1201 void setupscreen()
19722 {
19723 1201 boughtsomething=false;
19724 1201 int32_t t=currscr<128?0:1;
19725 1201 word str=tmpscr[t].str;
19726
19727 // Prices are already set to 0 in dowarp()
19728
14/15
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 683 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 17 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 19 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14 times.
1201 switch(tmpscr[t].room)
19729 {
19730 case rSP_ITEM: // special item
19731 161 additem(120,89,tmpscr[t].catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
19732 161 break;
19733
19734 case rINFO: // pay for info
19735 {
19736 28 int32_t count = 0;
19737 28 int32_t base = 88;
19738 28 int32_t step = 5;
19739
19740 28 moneysign();
19741
19742
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 84 times.
112 for(int32_t i=0; i<3; i++)
19743 {
19744
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(QMisc.info[tmpscr[t].catchall].str[i])
19745 {
19746 84 ++count;
19747 84 }
19748 else
19749 break;
19750 84 }
19751
19752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(count)
19753 {
19754
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==1)
19755 {
19756 base = 88+32;
19757 }
19758
19759
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==2)
19760 {
19761 step = 6;
19762 }
19763
19764
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 28 times.
112 for(int32_t i=0; i < count; i++)
19765 {
19766 84 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
19767 84 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19768 84 prices[i] = -(QMisc.info[tmpscr[t].catchall].price[i]);
19769
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(prices[i]==0)
19770 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19771 84 int32_t itemid = current_item_id(itype_wealthmedal);
19772
19773
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(itemid>=0 && prices[i]!=100000)
19774 {
19775 if(itemsbuf[itemid].flags & item_flag1)
19776 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19777 else
19778 prices[i]-=itemsbuf[itemid].misc1;
19779 prices[i]=vbound(prices[i], -99999, 0);
19780 if(prices[i]==0)
19781 prices[i]=100000;
19782 }
19783
19784
2/6
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if((QMisc.info[tmpscr[t].catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
19785 prices[i]=-1;
19786 84 }
19787 28 }
19788
19789 28 break;
19790 }
19791
19792 case rMONEY: // secret money
19793 44 additem(120,89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
19794 44 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19795 44 break;
19796
19797 case rGAMBLE: // gambling
19798 11 prices[0]=prices[1]=prices[2]=-10;
19799 11 moneysign();
19800 11 additem(88,89,iRupy,ipMONEY+ipDUMMY);
19801 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19802 11 additem(120,89,iRupy,ipMONEY+ipDUMMY);
19803 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19804 11 additem(152,89,iRupy,ipMONEY+ipDUMMY);
19805 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
19806 11 break;
19807
19808 case rREPAIR: // door repair
19809
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
19810 // }
19811 13 repaircharge=tmpscr[t].catchall;
19812 13 break;
19813
19814 case rMUPGRADE: // upgrade magic
19815 2 adjustmagic=true;
19816 2 break;
19817
19818 case rLEARNSLASH: // learn slash attack
19819 2 learnslash=true;
19820 2 break;
19821
19822 case rRP_HC: // heart container or red potion
19823 17 additem(88,89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
19824 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19825 17 additem(152,89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
19826 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19827 17 break;
19828
19829 case rP_SHOP: // potion shop
19830
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
19831 {
19832 12 str=0;
19833 12 break;
19834 }
19835
19836 [[fallthrough]];
19837 case rTAKEONE: // take one
19838 case rSHOP: // shop
19839 {
19840 194 int32_t count = 0;
19841 194 int32_t base = 88;
19842 194 int32_t step = 5;
19843
19844
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 193 times.
194 if(tmpscr[t].room != rTAKEONE)
19845 193 moneysign();
19846
19847 //count and align the stuff
19848
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 560 times.
717 for(int32_t i=0; i<3; ++i)
19849 {
19850
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 37 times.
560 if(QMisc.shop[tmpscr[t].catchall].hasitem[count] != 0)
19851 {
19852 523 ++count;
19853 523 }
19854 else
19855 {
19856 37 break;
19857 }
19858 523 }
19859
19860
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 22 times.
194 if(count==1)
19861 {
19862 22 base = 88+32;
19863 22 }
19864
19865
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 15 times.
194 if(count==2)
19866 {
19867 15 step = 6;
19868 15 }
19869
19870
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 194 times.
717 for(int32_t i=0; i<count; i++)
19871 {
19872 523 additem((i<<step)+base, 89, QMisc.shop[tmpscr[t].catchall].item[i], ipHOLDUP+ipFADE+(tmpscr[t].room == rTAKEONE ? ipONETIME2 : ipCHECK));
19873 523 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19874
19875
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 521 times.
523 if(tmpscr[t].room != rTAKEONE)
19876 {
19877 521 prices[i] = QMisc.shop[tmpscr[t].catchall].price[i];
19878
1/2
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
521 if(prices[i]==0)
19879 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19880 521 int32_t itemid = current_item_id(itype_wealthmedal);
19881
19882
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
521 if(itemid>=0 && prices[i]!=100000)
19883 {
19884
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(itemsbuf[itemid].flags & item_flag1)
19885 9 prices[i]=((prices[i]*itemsbuf[itemid].misc1) / 100);
19886 else
19887 prices[i]+=itemsbuf[itemid].misc1;
19888 9 prices[i]=vbound(prices[i], 0, 99999);
19889
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(prices[i]==0)
19890 prices[i]=100000;
19891 9 }
19892
19893
2/4
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 521 times.
✗ Branch 3 not taken.
521 if((QMisc.shop[tmpscr[t].catchall].price[i])>1 && prices[i]<1)
19894 prices[i]=1;
19895 521 }
19896 523 }
19897
19898 194 break;
19899 }
19900 case rBOTTLESHOP: // bottle shop
19901 {
19902 1 int32_t count = 0;
19903 1 int32_t base = 88;
19904 1 int32_t step = 5;
19905
19906 1 moneysign();
19907 1 bottleshoptype const& bst = QMisc.bottle_shop_types[tmpscr[t].catchall];
19908 //count and align the stuff
19909
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<3; ++i)
19910 {
19911
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(bst.fill[count] != 0)
19912 {
19913 3 ++count;
19914 3 }
19915 else
19916 {
19917 break;
19918 }
19919 3 }
19920
19921
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==1)
19922 {
19923 base = 88+32;
19924 }
19925
19926
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==2)
19927 {
19928 step = 6;
19929 }
19930
19931
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t i=0; i<count; i++)
19932 {
19933 3 adddummyitem((i<<step)+base, 89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
19934 //{ Setup dummy item
19935 3 item* curItem = ((item*)items.spr(items.Count()-1));
19936 3 curItem->PriceIndex = i;
19937 3 newcombo const& cmb = combobuf[bst.comb[i]];
19938 3 curItem->o_tile = cmb.o_tile;
19939 3 curItem->o_cset = bst.cset[i];
19940 3 curItem->cs = curItem->o_cset;
19941 3 curItem->tile = cmb.o_tile;
19942 3 curItem->o_speed = cmb.speed;
19943 3 curItem->o_delay = 0;
19944 3 curItem->frames = cmb.frames;
19945 3 curItem->flip = cmb.flip;
19946 3 curItem->family = itype_bottlefill; //no pickup w/o empty bottle
19947 3 curItem->pstring = 0;
19948 3 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
19949 3 curItem->flash = false;
19950 3 curItem->twohand = false;
19951 3 curItem->anim = true;
19952 3 curItem->hit_width=1;
19953 3 curItem->hyofs=4;
19954 3 curItem->hit_height=12;
19955 3 curItem->script=0;
19956 3 curItem->txsz=1;
19957 3 curItem->tysz=1;
19958 //}
19959
19960 3 prices[i] = bst.price[i];
19961
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(prices[i]==0)
19962 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19963 3 int32_t itemid = current_item_id(itype_wealthmedal);
19964
19965
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(itemid>=0 && prices[i]!=100000)
19966 {
19967 if(itemsbuf[itemid].flags & item_flag1)
19968 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19969 else
19970 prices[i]+=itemsbuf[itemid].misc1;
19971 prices[i]=vbound(prices[i], 0, 99999);
19972 if(prices[i]==0)
19973 prices[i]=100000;
19974 }
19975
19976
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if((bst.price[i])>1 && prices[i]<1)
19977 prices[i]=1;
19978 3 }
19979
19980 1 break;
19981 }
19982
19983 case rBOMBS: // more bombs
19984 19 additem(120,89,iRupy,ipDUMMY+ipMONEY);
19985 19 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19986 19 prices[0]=-tmpscr[t].catchall;
19987 19 break;
19988
19989 case rARROWS: // more arrows
19990 additem(120,89,iRupy,ipDUMMY+ipMONEY);
19991 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19992 prices[0]=-tmpscr[t].catchall;
19993 break;
19994
19995 case rSWINDLE: // leave heart container or money
19996 14 additem(88,89,iHeartC,ipDUMMY+ipMONEY);
19997 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19998 14 prices[0]=-1;
19999 14 additem(152,89,iRupy,ipDUMMY+ipMONEY);
20000 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
20001 14 prices[1]=-tmpscr[t].catchall;
20002 14 break;
20003
20004 }
20005
20006
3/4
✓ Branch 0 taken 1182 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1182 times.
1201 if(tmpscr[t].room == rBOMBS || tmpscr[t].room == rARROWS)
20007 {
20008 19 int32_t i = (tmpscr[t].room == rSWINDLE ? 1 : 0);
20009 19 int32_t itemid = current_item_id(itype_wealthmedal);
20010
20011
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(itemid >= 0)
20012 {
20013 if(itemsbuf[itemid].flags & item_flag1)
20014 prices[i]*=(itemsbuf[itemid].misc1 /100.0);
20015 else
20016 prices[i]+=itemsbuf[itemid].misc1;
20017 }
20018
20019
2/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
19 if(tmpscr[t].catchall>1 && prices[i]>-1)
20020 prices[i]=-1;
20021 19 }
20022
20023 1201 putprices(false);
20024
20025
2/2
✓ Branch 0 taken 1142 times.
✓ Branch 1 taken 59 times.
1201 if(str)
20026 {
20027 1142 donewmsg(str);
20028 1142 }
20029 else
20030 {
20031 59 Hero.unfreeze();
20032 }
20033 1201 }
20034
20035 // Increments msgptr and returns the control code argument pointed at.
20036 4361 word grab_next_argument()
20037 {
20038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4361 times.
4361 if(unsigned(msgptr+1)>=MsgStrings[msgstr].s.size()) return 0;
20039 4361 byte val=MsgStrings[msgstr].s[++msgptr]-1;
20040 4361 word ret=val;
20041
20042 // If an argument is succeeded by 255, then it's a three-byte argument -
20043 // between 254 and 65535 (or whatever the maximum actually is)
20044
2/2
✓ Branch 0 taken 4197 times.
✓ Branch 1 taken 109 times.
4361 if((unsigned(msgptr+2)<MsgStrings[msgstr].s.size())
20045
2/2
✓ Branch 0 taken 4306 times.
✓ Branch 1 taken 55 times.
4361 && uint8_t(MsgStrings[msgstr].s[msgptr+1]) == 255)
20046 {
20047 109 val=MsgStrings[msgstr].s[msgptr+2];
20048 109 word next=val;
20049 109 ret += 254*next;
20050 109 msgptr+=2;
20051 109 }
20052
20053 4361 return ret;
20054 4361 }
20055
20056 enum
20057 {
20058 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
20059 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
20060
20061 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
20062
20063 MNU_DATA_MAX
20064 };
20065 struct menu_choice
20066 {
20067 int32_t x, y;
20068 int32_t pos;
20069 int32_t upos, dpos, lpos, rpos;
20070 8 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
20071 8 {}
20072 8 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
20073 int32_t dpos, int32_t lpos, int32_t rpos)
20074 8 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
20075 8 {}
20076 };
20077 static int32_t msg_menu_data[MNU_DATA_MAX];
20078 static bool do_run_menu = false;
20079 bool do_end_str = false;
20080 static bool wait_advance = false;
20081 357 static std::map<int32_t, menu_choice> menu_options;
20082 43237 void clr_msg_data()
20083 {
20084 43237 do_end_str = false;
20085 43237 wait_advance = false;
20086 43237 do_run_menu = false;
20087 43237 menu_options.clear();
20088 43237 memset(msg_menu_data, 0, sizeof(msg_menu_data));
20089 43237 }
20090
20091 static bool doing_name_insert = false;
20092 static char namebuf[9] = {0};
20093 static char* nameptr = NULL;
20094 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
20095 965 bool runMenuCursor()
20096 {
20097 965 clear_bitmap(msg_menu_bmp_buf);
20098
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!menu_options.size())
20099 {
20100 msg_menu_data[MNU_CHOSEN] = 0;
20101 return true; //end menu
20102 }
20103 965 int32_t pos = msg_menu_data[MNU_CHOSEN];
20104 //If the cursor is at an invalid pos, find the first pos >= 0...
20105
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(menu_options.find(pos) == menu_options.end())
20106 {
20107 pos = 0;
20108 while(menu_options.find(pos) == menu_options.end())
20109 ++pos;
20110 }
20111 965 menu_choice* ch = &menu_options[pos];
20112
20113 965 bool pressed = true;
20114
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 964 times.
965 if(rUp()) pos = ch->upos;
20115
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 962 times.
964 else if(rDown()) pos = ch->dpos;
20116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 962 times.
962 else if(rLeft()) pos = ch->lpos;
20117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 962 times.
962 else if(rRight()) pos = ch->rpos;
20118 962 else pressed = false;
20119
20120
2/2
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 3 times.
965 if(pressed)
20121 3 msg_menu_data[MNU_TIMER] = 1;
20122
20123 965 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
20124 965 bool held = false;
20125
2/2
✓ Branch 0 taken 917 times.
✓ Branch 1 taken 48 times.
965 if(hold_input)
20126 {
20127 48 held = true;
20128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(Up()) pos = ch->upos;
20129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 else if(Down()) pos = ch->dpos;
20130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 else if(Left()) pos = ch->lpos;
20131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 else if(Right()) pos = ch->rpos;
20132 48 else held = false;
20133 48 }
20134 //If the cursor is at an invalid pos, find the first pos >= 0...
20135
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(menu_options.find(pos) == menu_options.end())
20136 {
20137 pos = 0;
20138 while(menu_options.find(pos) == menu_options.end())
20139 ++pos;
20140 }
20141
4/4
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 962 times.
✓ Branch 3 taken 3 times.
965 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
20142 3 sfx(MsgStrings[msgstr].sfx);
20143
20144 965 ch = &menu_options[pos];
20145 1930 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
20146 965 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
20147 965 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
20148 965 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
20149
20150 965 msg_menu_data[MNU_CHOSEN] = pos;
20151
20152
2/2
✓ Branch 0 taken 941 times.
✓ Branch 1 taken 24 times.
965 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
20153 {
20154 24 rAbtn(); //Eat
20155
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 2 times.
24 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
20156 24 }
20157
20158
3/4
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 962 times.
965 bool ret = (pressed || held) ? false : rAbtn();
20159 //Eat inputs
20160 965 rUp(); rDown(); rLeft(); rRight(); rAbtn();
20161
20162
2/2
✓ Branch 0 taken 963 times.
✓ Branch 1 taken 2 times.
965 if(ret)
20163 2 menu_options.clear();
20164
20165 965 return ret;
20166 //false if pos changed this frame; no confirming while moving the cursor!
20167 965 }
20168
20169 697955 bool bottom_margin_clip()
20170 {
20171 757288 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
20172
2/2
✓ Branch 0 taken 638622 times.
✓ Branch 1 taken 59333 times.
697955 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
20173 }
20174
20175 void update_msgstr();
20176 245901 bool parsemsgcode()
20177 {
20178
2/2
✓ Branch 0 taken 2759 times.
✓ Branch 1 taken 243142 times.
245901 if(msgptr>=MsgStrings[msgstr].s.size()) return false;
20179 243142 byte c = byte(MsgStrings[msgstr].s[msgptr]-1);
20180
19/39
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 239611 times.
✓ Branch 2 taken 1284 times.
✓ Branch 3 taken 1879 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 57 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 68 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 9 times.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 7 times.
✓ Branch 16 taken 6 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 122 times.
✓ Branch 25 taken 29 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 2 times.
✓ Branch 30 taken 8 times.
✓ Branch 31 taken 2 times.
✓ Branch 32 taken 4 times.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
243142 switch(c)
20181 {
20182 case MSGC_NEWLINE:
20183 {
20184 1284 ssc_tile_hei = ssc_tile_hei_buf;
20185
1/2
✓ Branch 0 taken 1284 times.
✗ Branch 1 not taken.
1284 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20186 1284 ssc_tile_hei_buf = -1;
20187 1284 cursor_y += thei + MsgStrings[msgstr].vspace;
20188 1284 cursor_x=msg_margins[left];
20189 1284 return true;
20190 }
20191
20192 case MSGC_COLOUR:
20193 {
20194 1879 int32_t cset = (grab_next_argument());
20195 1879 msgcolour = CSET(cset)+(grab_next_argument());
20196 1879 return true;
20197 }
20198
20199 case MSGC_SHDCOLOR:
20200 {
20201 int32_t cset = (grab_next_argument());
20202 msg_shdcol = CSET(cset)+(grab_next_argument());
20203 return true;
20204 }
20205 case MSGC_SHDTYPE:
20206 {
20207 msg_shdtype = grab_next_argument();
20208 return true;
20209 }
20210
20211 case MSGC_SPEED:
20212 {
20213 57 msgspeed=grab_next_argument();
20214 57 return true;
20215 }
20216
20217 case MSGC_CTRUP:
20218 {
20219 int32_t a1 = grab_next_argument();
20220 int32_t a2 = grab_next_argument();
20221 game->change_counter(a2, a1);
20222 return true;
20223 }
20224
20225 case MSGC_CTRDN:
20226 {
20227 2 int32_t a1 = grab_next_argument();
20228 2 int32_t a2 = grab_next_argument();
20229 2 game->change_counter(-a2, a1);
20230 2 return true;
20231 }
20232
20233 case MSGC_CTRSET:
20234 {
20235 16 int32_t a1 = grab_next_argument();
20236 16 int32_t a2 = grab_next_argument();
20237 16 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20238 16 return true;
20239 }
20240
20241 case MSGC_CTRUPPC:
20242 case MSGC_CTRDNPC:
20243 case MSGC_CTRSETPC:
20244 {
20245 2 int32_t code = MsgStrings[msgstr].s[msgptr]-1;
20246 2 int32_t counter = grab_next_argument();
20247 2 int32_t amount = grab_next_argument();
20248 2 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20249
20250
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(code==MSGC_CTRDNPC)
20251 amount*=-1;
20252
20253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(code==MSGC_CTRSETPC)
20254 game->set_counter(amount, counter);
20255 else
20256 2 game->change_counter(amount, counter);
20257
20258 2 return true;
20259 }
20260
20261 case MSGC_GIVEITEM:
20262 {
20263 68 int32_t itemID = grab_next_argument();
20264
20265 68 getitem(itemID, true);
20266
2/4
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 68 times.
68 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20267 {
20268 68 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20269 68 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&item_passive_script) > 0;
20270 68 }
20271 68 return true;
20272 }
20273
20274
20275 case MSGC_WARP:
20276 {
20277 int32_t dmap = grab_next_argument();
20278 int32_t scrn = grab_next_argument();
20279 int32_t dx = grab_next_argument();
20280 int32_t dy = grab_next_argument();
20281 int32_t wfx = grab_next_argument();
20282 int32_t sfx = grab_next_argument();
20283 if(dx >= MAX_SCC_ARG) dx = -1;
20284 if(dy >= MAX_SCC_ARG) dy = -1;
20285 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, 0, 0);
20286 do_end_str = true;
20287 return true;
20288 }
20289
20290 case MSGC_SETSCREEND:
20291 {
20292 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20293 int32_t screen = grab_next_argument();
20294 int32_t reg = grab_next_argument();
20295 int32_t val = grab_next_argument();
20296 FFCore.set_screen_d(screen + dmap, reg, val);
20297 return true;
20298 }
20299 case MSGC_TAKEITEM:
20300 {
20301 9 int32_t itemID = grab_next_argument();
20302
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( FFCore.doscript(ScriptType::Item, itemID) )
20303 {
20304 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20305 }
20306 9 takeitem(itemID);
20307
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_bwpn == itemID )
20308 {
20309 game->forced_bwpn = -1;
20310 } //not else if! -Z
20311
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_awpn == itemID )
20312 {
20313 game->forced_awpn = -1;
20314 }
20315
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_xwpn == itemID )
20316 {
20317 game->forced_xwpn = -1;
20318 } //not else if! -Z
20319
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_ywpn == itemID )
20320 {
20321 game->forced_ywpn = -1;
20322 }
20323 9 verifyBothWeapons();
20324 9 return true;
20325 }
20326
20327 case MSGC_SFX:
20328 {
20329 33 sfx((int32_t)grab_next_argument(),128);
20330 33 return true;
20331 }
20332
20333 case MSGC_MIDI:
20334 {
20335 7 int32_t music = (int32_t)(grab_next_argument());
20336
20337
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 if(music==0)
20338 1 music_stop();
20339 else
20340 6 jukebox(music+(ZC_MIDI_COUNT-1));
20341
20342 7 return true;
20343 }
20344
20345 case MSGC_NAME:
20346 {
20347 6 doing_name_insert = true;
20348 6 sprintf(namebuf, "%s", game->get_name());
20349 6 nameptr = namebuf;
20350 6 return true;
20351 }
20352
20353 case MSGC_FONT:
20354 {
20355 int fontid = grab_next_argument();
20356 int oh = text_height(msgfont);
20357 msgfont = get_zc_font(fontid);
20358 int nh = text_height(msgfont);
20359 int mh = std::max(oh,nh);
20360 if(mh > ssc_tile_hei_buf)
20361 ssc_tile_hei_buf = mh;
20362 return true;
20363 }
20364 case MSGC_RUN_FRZ_GENSCR:
20365 {
20366 word scr_id = grab_next_argument();
20367 bool force_redraw = grab_next_argument()!=0;
20368 if(force_redraw)
20369 {
20370 update_msgstr();
20371 draw_screen(tmpscr);
20372 }
20373 FFCore.runGenericFrozenEngine(scr_id);
20374 return true;
20375 }
20376 case MSGC_DRAWTILE:
20377 {
20378 int32_t tl = grab_next_argument();
20379 int32_t cs = grab_next_argument();
20380 int32_t t_wid = grab_next_argument();
20381 int32_t t_hei = grab_next_argument();
20382 int32_t fl = grab_next_argument();
20383
20384 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20385 {
20386 ssc_tile_hei = ssc_tile_hei_buf;
20387 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20388 ssc_tile_hei_buf = -1;
20389 cursor_y += thei + MsgStrings[msgstr].vspace;
20390 if(bottom_margin_clip()) return true;
20391 cursor_x=msg_margins[left];
20392 }
20393
20394 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20395 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20396 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20397 return true;
20398 }
20399
20400 case MSGC_GOTOIFRAND:
20401 {
20402 int32_t odds = (int32_t)(grab_next_argument());
20403
20404 if(!odds || !(zc_oldrand()%odds))
20405 goto switched;
20406
20407 (void)grab_next_argument();
20408 return true;
20409 }
20410
20411 case MSGC_GOTOIFGLOBAL:
20412 {
20413 int32_t arg = (int32_t)grab_next_argument();
20414 int32_t d = zc_min(7,arg);
20415 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20416 arg = (int32_t)grab_next_argument();
20417
20418 if(game->screen_d[s][d] >= arg)
20419 goto switched;
20420
20421 (void)grab_next_argument();
20422 return true;
20423 }
20424
20425 case MSGC_CHANGEPORTRAIT:
20426 {
20427 return true; //not implemented
20428 }
20429
20430 case MSGC_GOTOIFCREEND:
20431 {
20432 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20433 int32_t screen = grab_next_argument();
20434 int32_t reg = grab_next_argument();
20435 int32_t val = grab_next_argument();
20436 //int32_t nxtstr = grab_next_argument();
20437 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20438 {
20439 goto switched;
20440 }
20441 (void)grab_next_argument();
20442 return true;
20443 }
20444
20445 case MSGC_GOTOIF:
20446 {
20447 122 int32_t it = (int32_t)grab_next_argument();
20448
20449
3/4
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 35 times.
122 if(unsigned(it)<MAXITEMS && game->item[it])
20450 35 goto switched;
20451
20452 87 (void)grab_next_argument();
20453 87 return true;
20454 }
20455
20456 case MSGC_GOTOIFCTR:
20457 {
20458
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 14 times.
29 if(game->get_counter(grab_next_argument())>=grab_next_argument())
20459 15 goto switched;
20460
20461 14 (void)grab_next_argument();
20462 14 return true;
20463 }
20464
20465 case MSGC_GOTOIFCTRPC:
20466 {
20467 int32_t counter = grab_next_argument();
20468 int32_t amount = (int32_t)(((grab_next_argument())/100)*game->get_maxcounter(counter));
20469
20470 if(game->get_counter(counter)>=amount)
20471 goto switched;
20472
20473 (void)grab_next_argument();
20474 return true;
20475 }
20476
20477 case MSGC_GOTOIFTRICOUNT:
20478 {
20479 if(TriforceCount() >= (int32_t)(grab_next_argument()))
20480 goto switched;
20481
20482 (void)grab_next_argument();
20483 return true;
20484 }
20485
20486 case MSGC_GOTOIFTRI:
20487 {
20488 int32_t lev = (int32_t)(grab_next_argument());
20489
20490 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
20491 goto switched;
20492
20493 (void)grab_next_argument();
20494 return true;
20495 }
20496
20497 case MSGC_SETUPMENU:
20498 {
20499 2 msg_menu_data[MNU_CURSOR_TILE] = grab_next_argument();
20500 2 msg_menu_data[MNU_CURSOR_CSET] = grab_next_argument();
20501 2 msg_menu_data[MNU_CURSOR_WID] = grab_next_argument();
20502 2 msg_menu_data[MNU_CURSOR_HEI] = grab_next_argument();
20503 2 msg_menu_data[MNU_CURSOR_FLIP] = grab_next_argument();
20504 2 return true;
20505 }
20506
20507 case MSGC_MENUCHOICE:
20508 {
20509 8 int32_t pos = grab_next_argument();
20510 8 int32_t upos = grab_next_argument();
20511 8 int32_t dpos = grab_next_argument();
20512 8 int32_t lpos = grab_next_argument();
20513 8 int32_t rpos = grab_next_argument();
20514
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20515 {
20516 2 ssc_tile_hei = ssc_tile_hei_buf;
20517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20518 2 ssc_tile_hei_buf = -1;
20519 2 cursor_y += thei + MsgStrings[msgstr].vspace;
20520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(bottom_margin_clip()) break;
20521 2 cursor_x=msg_margins[left];
20522 2 }
20523
20524 16 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
20525 8 upos, dpos, lpos, rpos);
20526
20527
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
8 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
20528 8 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
20529 8 return true;
20530 }
20531
20532 case MSGC_RUNMENU:
20533 {
20534 2 msg_menu_data[MNU_CHOSEN] = 0;
20535 2 msg_menu_data[MNU_CAN_CONFIRM] = 0;
20536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(menu_options.size() < 1)
20537 return true;
20538 2 do_run_menu = true;
20539 2 return true;
20540 }
20541
20542 case MSGC_GOTOMENUCHOICE:
20543 {
20544 4 int32_t choice = grab_next_argument();
20545
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if(msg_menu_data[MNU_CHOSEN] == choice)
20546 2 goto switched;
20547 2 (void)grab_next_argument();
20548 2 return true;
20549 }
20550
20551 case MSGC_ENDSTRING:
20552 {
20553 1 do_end_str = true;
20554 1 return true;
20555 }
20556 case MSGC_WAIT_ADVANCE:
20557 {
20558 wait_advance = true;
20559 linkedmsgclk = 51;
20560 return true;
20561 }
20562 case MSGC_TRIGSECRETS:
20563 {
20564 bool perm = (bool)grab_next_argument();
20565 hidden_entrance(0, true, false, -8);
20566 if(perm)
20567 setmapflag(mSECRET);
20568 return true;
20569 }
20570 case MSGC_TRIG_CMB_COPYCAT:
20571 {
20572 int copy_id = (int)grab_next_argument();
20573 if(copy_id == byte(copy_id))
20574 trig_copycat(copy_id);
20575 return true;
20576 }
20577 case MSGC_SETSCREENSTATE:
20578 {
20579 int32_t flag = int32_t(grab_next_argument());
20580 if(unsigned(flag)>=mMAXIND)
20581 {
20582 Z_error("SCC 133: Flag %d is invalid\n", flag);
20583 return true;
20584 }
20585 bool state = bool(grab_next_argument());
20586 if(state)
20587 setmapflag(1<<flag);
20588 else
20589 unsetmapflag(1<<flag,true);
20590 return true;
20591 }
20592 case MSGC_SETSCREENSTATER:
20593 {
20594 int32_t map = (int32_t)grab_next_argument();
20595 int32_t scrid = (int32_t)grab_next_argument();
20596 if(map < 1 || map > map_count)
20597 {
20598 Z_error("SCC 134: Map %d is invalid\n", map);
20599 return true;
20600 }
20601 if(unsigned(scrid)>=0x80)
20602 {
20603 Z_error("SCC 134: Screen %d is invalid\n", scrid);
20604 return true;
20605 }
20606
20607 int32_t flag = int32_t(grab_next_argument());
20608 if(unsigned(flag)>=mMAXIND)
20609 {
20610 Z_error("SCC 134: Flag %d is invalid\n", flag);
20611 return true;
20612 }
20613 bool state = bool(grab_next_argument());
20614 if(state)
20615 setmapflag(mapind(map,scrid),1<<flag);
20616 else
20617 unsetmapflag(mapind(map,scrid),1<<flag,true);
20618 return true;
20619 }
20620 switched:
20621 52 int32_t lev = (int32_t)(grab_next_argument());
20622
2/4
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
52 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
20623
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 39 times.
52 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
20624 {
20625 msgstr=lev;
20626 msgpos=msgptr=0;
20627 msgfont=setmsgfont();
20628 }
20629 else
20630 {
20631 52 donewmsg(lev);
20632 52 ssc_tile_hei_buf = -1;
20633 }
20634 52 msgptr--; // To counteract it being incremented after this routine is called.
20635 52 putprices(false);
20636 52 return true;
20637 }
20638
20639 239611 return false;
20640 245901 }
20641
20642 // Wraps the message string... probably.
20643 236093 void wrapmsgstr(char *s3)
20644 {
20645 236093 int32_t j=0;
20646
20647
2/2
✓ Branch 0 taken 23941 times.
✓ Branch 1 taken 212152 times.
236093 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
20648 {
20649
2/2
✓ Branch 0 taken 4767 times.
✓ Branch 1 taken 19174 times.
23941 if(msgspace)
20650 {
20651 4767 char c = MsgStrings[msgstr].s[msgptr];
20652
4/6
✓ Branch 0 taken 4440 times.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4440 times.
✗ Branch 5 not taken.
4767 if(c != ' ' && c >= 32 && c <= 126)
20653 {
20654
4/4
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 24450 times.
✓ Branch 2 taken 20132 times.
✓ Branch 3 taken 4440 times.
24572 for(int32_t k=0; MsgStrings[msgstr].s[msgptr+k] && MsgStrings[msgstr].s[msgptr+k] != ' '; k++)
20655 {
20656
3/4
✓ Branch 0 taken 19569 times.
✓ Branch 1 taken 563 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19569 times.
20132 if(MsgStrings[msgstr].s[msgptr+k] >= 32 && MsgStrings[msgstr].s[msgptr+k] <= 126) s3[j++] = MsgStrings[msgstr].s[msgptr+k];
20657 20132 }
20658
20659 4440 s3[j] = 0;
20660 4440 msgspace = false;
20661 4440 }
20662 else
20663 {
20664 327 s3[0] = c;
20665 327 s3[1] = 0;
20666 }
20667 4767 }
20668 else
20669 {
20670 19174 s3[0] = MsgStrings[msgstr].s[msgptr];
20671 19174 s3[1] = 0;
20672
20673
2/2
✓ Branch 0 taken 15129 times.
✓ Branch 1 taken 4045 times.
19174 if(s3[0] == ' ') msgspace=true;
20674 }
20675 23941 }
20676 else
20677 {
20678 212152 s3[0] = MsgStrings[msgstr].s[msgptr];
20679 212152 s3[1] = 0;
20680 }
20681 236093 }
20682
20683 // Returns true if the pointer is at a string's
20684 // null terminator or a trailing space
20685 814102 bool atend(char const* str)
20686 {
20687 814102 int32_t i=0;
20688
20689
2/2
✓ Branch 0 taken 6343291 times.
✓ Branch 1 taken 814102 times.
7157393 while(str[i]==' ')
20690 6343291 i++;
20691
20692 814102 return str[i]=='\0';
20693 }
20694
20695 14472280 void putmsg()
20696 {
20697 14472280 bool oldmargin = get_qr(qr_OLD_STRING_EDITOR_MARGINS)!=0;
20698
2/2
✓ Branch 0 taken 691102 times.
✓ Branch 1 taken 13781178 times.
14472280 if(!msgorig) msgorig=msgstr;
20699
20700
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14472280 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14472280 if(wait_advance && linkedmsgclk < 1)
20701 linkedmsgclk = 1;
20702
2/2
✓ Branch 0 taken 14195925 times.
✓ Branch 1 taken 276355 times.
14472280 if(linkedmsgclk>0)
20703 {
20704
2/2
✓ Branch 0 taken 126304 times.
✓ Branch 1 taken 150051 times.
276355 if(linkedmsgclk==1)
20705 {
20706
6/6
✓ Branch 0 taken 126303 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 123411 times.
✓ Branch 3 taken 2892 times.
✓ Branch 4 taken 108 times.
✓ Branch 5 taken 123303 times.
126304 if(do_end_str||cAbtn()||cBbtn())
20707 {
20708 3001 do_end_str = false;
20709 3001 linkedmsgclk = 0;
20710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3001 times.
3001 if(wait_advance)
20711 {
20712 wait_advance = false;
20713 }
20714 else
20715 {
20716 3001 msgstr=MsgStrings[msgstr].nextstring;
20717 3001 ssc_tile_hei_buf = -1;
20718
3/4
✓ Branch 0 taken 1007 times.
✓ Branch 1 taken 1994 times.
✓ Branch 2 taken 1007 times.
✗ Branch 3 not taken.
3001 if(!msgstr && enqueued_str)
20719 {
20720 msgstr = enqueued_str;
20721 enqueued_str = 0;
20722 }
20723
2/2
✓ Branch 0 taken 1994 times.
✓ Branch 1 taken 1007 times.
3001 if(!msgstr)
20724 {
20725 1007 msgfont=get_zc_font(font_zfont);
20726
20727
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1003 times.
1007 if(tmpscr->room!=rGRUMBLE)
20728 1003 blockpath=false;
20729
20730 1007 dismissmsg();
20731 1007 goto disappear;
20732 }
20733
20734 1994 donewmsg(msgstr);
20735 1994 putprices(false);
20736 }
20737 1994 }
20738 125297 }
20739 else
20740 {
20741 150051 --linkedmsgclk;
20742 }
20743 275348 }
20744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14471273 times.
14471273 if(wait_advance) return; //Waiting for buttonpress
20745
20746
10/10
✓ Branch 0 taken 14468966 times.
✓ Branch 1 taken 2307 times.
✓ Branch 2 taken 685865 times.
✓ Branch 3 taken 13783101 times.
✓ Branch 4 taken 549212 times.
✓ Branch 5 taken 136653 times.
✓ Branch 6 taken 282168 times.
✓ Branch 7 taken 267044 times.
✓ Branch 8 taken 854 times.
✓ Branch 9 taken 281314 times.
14471273 if(!do_run_menu && (!msgstr || msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip()))
20747 {
20748
2/2
✓ Branch 0 taken 404551 times.
✓ Branch 1 taken 13783101 times.
14187652 if(!msgstr)
20749 13783101 msgorig=0;
20750
20751 14187652 msg_active = false;
20752 14187652 return;
20753 }
20754
20755 283621 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
20756
20757 char s3[145];
20758 int32_t tlength;
20759
20760 // Bypass the string with the B button!
20761
4/4
✓ Branch 0 taken 1343 times.
✓ Branch 1 taken 282278 times.
✓ Branch 2 taken 1242 times.
✓ Branch 3 taken 281036 times.
283621 if(((cBbtn())&&(get_qr(qr_ALLOWMSGBYPASS))) || msgspeed==0)
20762 {
20763 //finish writing out the string
20764
4/4
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 79133 times.
✓ Branch 2 taken 1232 times.
✓ Branch 3 taken 78004 times.
80580 while(msgptr<MsgStrings[msgstr].s.size() && !atend(MsgStrings[msgstr].s.c_str()+msgptr))
20765 {
20766
5/6
✓ Branch 0 taken 18716 times.
✓ Branch 1 taken 59288 times.
✓ Branch 2 taken 18707 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 18707 times.
✗ Branch 5 not taken.
78004 if(msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
20767 9 goto breakout; // break out if message speed was changed to non-zero
20768
4/6
✓ Branch 0 taken 77995 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77995 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 293 times.
✓ Branch 5 taken 77702 times.
77995 else if(!do_run_menu && !doing_name_insert && !parsemsgcode())
20769 {
20770
1/2
✓ Branch 0 taken 77702 times.
✗ Branch 1 not taken.
77702 if(bottom_margin_clip())
20771 break;
20772
20773 77702 wrapmsgstr(s3);
20774
20775
2/2
✓ Branch 0 taken 20449 times.
✓ Branch 1 taken 57253 times.
77702 if(MsgStrings[msgstr].s[msgptr]==' ')
20776 {
20777 20449 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
20778
20779
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 1347 times.
21843 if(cursor_x+tlength > (msg_w-msg_margins[right])
20780
5/6
✓ Branch 0 taken 1394 times.
✓ Branch 1 taken 19055 times.
✓ Branch 2 taken 1394 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1300 times.
✓ Branch 5 taken 47 times.
20449 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20781 47 ? true : strcmp(s3," ")!=0))
20782 {
20783 1347 ssc_tile_hei = ssc_tile_hei_buf;
20784
1/2
✓ Branch 0 taken 1347 times.
✗ Branch 1 not taken.
1347 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20785 1347 ssc_tile_hei_buf = -1;
20786 1347 cursor_y += thei + MsgStrings[msgstr].vspace;
20787
1/2
✓ Branch 0 taken 1347 times.
✗ Branch 1 not taken.
1347 if(bottom_margin_clip()) break;
20788 1347 cursor_x=msg_margins[left];
20789 1347 }
20790
20791 20449 char buf[2] = {0};
20792 20449 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
20793
20794 20449 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
20795
20796 20449 cursor_x+=tlength;
20797 20449 }
20798 else
20799 {
20800 57253 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
20801
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 536 times.
57979 if(cursor_x+tlength > (msg_w-msg_margins[right])
20802
5/6
✓ Branch 0 taken 773 times.
✓ Branch 1 taken 56480 times.
✓ Branch 2 taken 726 times.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 583 times.
✗ Branch 5 not taken.
57253 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20803 190 ? true : strcmp(s3," ")!=0))
20804 {
20805 773 ssc_tile_hei = ssc_tile_hei_buf;
20806
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20807 773 ssc_tile_hei_buf = -1;
20808 773 cursor_y += thei + MsgStrings[msgstr].vspace;
20809
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(bottom_margin_clip()) break;
20810 773 cursor_x=msg_margins[left];
20811 773 }
20812
20813 57253 sfx(MsgStrings[msgstr].sfx);
20814
20815 57253 char buf[2] = {0};
20816 57253 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
20817
20818 57253 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
20819
20820 57253 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
20821 57253 cursor_x += MsgStrings[msgstr].hspace;
20822 }
20823
20824 77702 msgpos++;
20825 77702 }
20826
1/2
✓ Branch 0 taken 77995 times.
✗ Branch 1 not taken.
77995 if(do_run_menu)
20827 {
20828 if(runMenuCursor())
20829 {
20830 do_run_menu = false;
20831 }
20832 else break;
20833 }
20834
1/2
✓ Branch 0 taken 77995 times.
✗ Branch 1 not taken.
77995 if(doing_name_insert)
20835 {
20836 if(*nameptr)
20837 {
20838 if(bottom_margin_clip())
20839 break;
20840
20841 char s3[9] = {0};
20842
20843 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
20844 {
20845 strcpy(s3, nameptr);
20846 }
20847 else
20848 {
20849 s3[0] = *nameptr;
20850 s3[1] = 0;
20851 }
20852
20853 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
20854
20855 if(cursor_x+tlength > (msg_w-msg_margins[right])
20856 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20857 ? true : strcmp(s3," ")!=0))
20858 {
20859 ssc_tile_hei = ssc_tile_hei_buf;
20860 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20861 ssc_tile_hei_buf = -1;
20862 cursor_y += thei + MsgStrings[msgstr].vspace;
20863 if(bottom_margin_clip()) break;
20864 cursor_x=msg_margins[left];
20865 }
20866
20867 sfx(MsgStrings[msgstr].sfx);
20868
20869 char buf[2] = {0};
20870 sprintf(buf,"%c",*nameptr);
20871
20872 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
20873
20874 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
20875 cursor_x += MsgStrings[msgstr].hspace;
20876 ++nameptr;
20877 continue; //don't advance the msgptr, as the next char in it was not processed!
20878 }
20879 else doing_name_insert = false;
20880 }
20881 77995 ++msgptr;
20882
1/2
✓ Branch 0 taken 77995 times.
✗ Branch 1 not taken.
77995 if(do_end_str)
20883 goto strendcheck;
20884
1/2
✓ Branch 0 taken 77995 times.
✗ Branch 1 not taken.
77995 if(wait_advance)
20885 return;
20886
2/2
✓ Branch 0 taken 76782 times.
✓ Branch 1 taken 1213 times.
77995 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
20887 {
20888
2/2
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 786 times.
1213 if(MsgStrings[msgstr].nextstring)
20889 {
20890
1/2
✓ Branch 0 taken 786 times.
✗ Branch 1 not taken.
786 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20891 {
20892 msgstr=MsgStrings[msgstr].nextstring;
20893 msgpos=msgptr=0;
20894 msgfont=setmsgfont();
20895 }
20896 786 }
20897 1213 }
20898 }
20899
20900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1232 times.
1232 if (!do_run_menu)
20901 {
20902 1232 msgclk = 72;
20903 1232 msgpos = 10000;
20904 1232 }
20905 1232 }
20906 else
20907 281036 {
20908 breakout:
20909 281045 word tempspeed = msgspeed;
20910
2/2
✓ Branch 0 taken 280082 times.
✓ Branch 1 taken 963 times.
281045 if (do_run_menu)
20911 963 tempspeed = 0;
20912
6/6
✓ Branch 0 taken 226539 times.
✓ Branch 1 taken 54506 times.
✓ Branch 2 taken 136038 times.
✓ Branch 3 taken 90501 times.
✓ Branch 4 taken 113455 times.
✓ Branch 5 taken 22583 times.
281045 if(((msgclk++)%(tempspeed+1)<tempspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG))))
20913 113084 return;
20914 }
20915
20916 // Start writing the string
20917
2/2
✓ Branch 0 taken 166230 times.
✓ Branch 1 taken 2963 times.
172156 if(msgptr == 0)
20918 {
20919
2/2
✓ Branch 0 taken 2963 times.
✓ Branch 1 taken 5068 times.
8031 while(MsgStrings[msgstr].s[msgptr]==' ')
20920 {
20921 5068 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
20922
20923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
5156 if(cursor_x+tlength > (msg_w-msg_margins[right])
20924
4/6
✓ Branch 0 taken 4980 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 88 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
5068 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20925 ? 1 : strcmp(s3," ")!=0))
20926 {
20927 88 ssc_tile_hei = ssc_tile_hei_buf;
20928
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20929 88 ssc_tile_hei_buf = -1;
20930 88 cursor_y += thei + MsgStrings[msgstr].vspace;
20931
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(bottom_margin_clip()) break;
20932 88 cursor_x=msg_margins[left];
20933 88 }
20934
20935 5068 cursor_x+=tlength;
20936 5068 ++msgptr;
20937 5068 ++msgpos;
20938
20939 // The "Continue From Previous" feature
20940
2/2
✓ Branch 0 taken 3700 times.
✓ Branch 1 taken 1368 times.
5068 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
20941 {
20942
1/2
✓ Branch 0 taken 1368 times.
✗ Branch 1 not taken.
1368 if(MsgStrings[msgstr].nextstring)
20943 {
20944 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20945 {
20946 msgstr=MsgStrings[msgstr].nextstring;
20947 msgpos=msgptr=0;
20948 msgfont=setmsgfont();
20949 }
20950 }
20951 1368 }
20952 }
20953 2963 }
20954
20955 reparsesinglechar:
20956 // Continue printing the string!
20957
3/4
✓ Branch 0 taken 162616 times.
✓ Branch 1 taken 6579 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 162616 times.
331808 if(!atend(MsgStrings[msgstr].s.c_str()+msgptr) && !bottom_margin_clip())
20958 {
20959
6/6
✓ Branch 0 taken 161653 times.
✓ Branch 1 taken 963 times.
✓ Branch 2 taken 161629 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 3238 times.
✓ Branch 5 taken 158391 times.
162616 if(!do_run_menu && !doing_name_insert && !parsemsgcode())
20960 {
20961 158391 wrapmsgstr(s3);
20962
20963 158391 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
20964
20965
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1923 times.
160570 if(cursor_x+tlength > (msg_w-msg_margins[right])
20966
6/6
✓ Branch 0 taken 2222 times.
✓ Branch 1 taken 156169 times.
✓ Branch 2 taken 2179 times.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 1923 times.
✓ Branch 5 taken 43 times.
158391 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20967 256 ? true : strcmp(s3," ")!=0))
20968 {
20969 2179 ssc_tile_hei = ssc_tile_hei_buf;
20970
1/2
✓ Branch 0 taken 2179 times.
✗ Branch 1 not taken.
2179 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20971 2179 ssc_tile_hei_buf = -1;
20972 2179 cursor_y += thei + MsgStrings[msgstr].vspace;
20973
1/2
✓ Branch 0 taken 2179 times.
✗ Branch 1 not taken.
2179 if(bottom_margin_clip()) goto strendcheck;
20974 2179 cursor_x=msg_margins[left];
20975 //if(space) s3[0]=0;
20976 2179 }
20977
20978 158391 sfx(MsgStrings[msgstr].sfx);
20979
20980 158391 char buf[2] = {0};
20981 158391 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
20982
20983 158391 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
20984
20985 158391 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
20986 158391 cursor_x += MsgStrings[msgstr].hspace;
20987 158391 msgpos++;
20988 158391 }
20989
2/2
✓ Branch 0 taken 162615 times.
✓ Branch 1 taken 1 times.
162616 if(do_end_str)
20990 1 goto strendcheck;
20991
1/2
✓ Branch 0 taken 162615 times.
✗ Branch 1 not taken.
162615 if(wait_advance)
20992 {
20993 ++msgptr;
20994 return;
20995 }
20996
2/2
✓ Branch 0 taken 965 times.
✓ Branch 1 taken 161650 times.
162615 else if(do_run_menu)
20997 {
20998
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 963 times.
965 if(runMenuCursor())
20999 {
21000 2 do_run_menu = false;
21001 2 ++msgptr;
21002 2 goto reparsesinglechar;
21003 }
21004 963 }
21005
4/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 161620 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 24 times.
161650 else if(doing_name_insert && *nameptr)
21006 {
21007 24 char s3[9] = {0};
21008
21009
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
21010 {
21011 24 strcpy(s3, nameptr);
21012 24 }
21013 else
21014 {
21015 s3[0] = *nameptr;
21016 s3[1] = 0;
21017 }
21018
21019 24 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21020
21021
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
24 if(cursor_x+tlength > (msg_w-msg_margins[right])
21022
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21023 ? true : strcmp(s3," ")!=0))
21024 {
21025 ssc_tile_hei = ssc_tile_hei_buf;
21026 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21027 ssc_tile_hei_buf = -1;
21028 cursor_y += thei + MsgStrings[msgstr].vspace;
21029 if(bottom_margin_clip()) goto strendcheck;
21030 cursor_x=msg_margins[left];
21031 }
21032
21033 24 sfx(MsgStrings[msgstr].sfx);
21034
21035 24 char buf[2] = {0};
21036 24 sprintf(buf,"%c",*nameptr);
21037
21038 24 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21039
21040 24 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
21041 24 cursor_x += MsgStrings[msgstr].hspace;
21042 24 ++nameptr;
21043 24 }
21044 else
21045 {
21046 161626 doing_name_insert = false;
21047 161626 msgptr++;
21048
21049
2/2
✓ Branch 0 taken 158861 times.
✓ Branch 1 taken 2765 times.
161626 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21050 {
21051
2/2
✓ Branch 0 taken 1556 times.
✓ Branch 1 taken 1209 times.
2765 if(MsgStrings[msgstr].nextstring)
21052 {
21053
1/2
✓ Branch 0 taken 1209 times.
✗ Branch 1 not taken.
1209 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21054 {
21055 msgstr=MsgStrings[msgstr].nextstring;
21056 msgpos=msgptr=0;
21057 msgfont=setmsgfont();
21058 }
21059 1209 }
21060 2765 }
21061
21062
2/2
✓ Branch 0 taken 23767 times.
✓ Branch 1 taken 4519 times.
189912 if(MsgStrings[msgstr].s.size() > unsigned(msgptr+1)
21063
2/2
✓ Branch 0 taken 160969 times.
✓ Branch 1 taken 657 times.
161626 && (MsgStrings[msgstr].s[msgptr]==' ')
21064
2/2
✓ Branch 0 taken 28286 times.
✓ Branch 1 taken 132683 times.
160969 && (MsgStrings[msgstr].s[msgptr+1]==' '))
21065 {
21066
2/2
✓ Branch 0 taken 4513 times.
✓ Branch 1 taken 156761 times.
161274 while(MsgStrings[msgstr].s[msgptr]==' ')
21067 {
21068 156761 msgspace = true;
21069 156761 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21070
21071
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 6280 times.
163505 if(cursor_x+tlength > (msg_w-msg_margins[right])
21072
4/6
✓ Branch 0 taken 6744 times.
✓ Branch 1 taken 150017 times.
✓ Branch 2 taken 6744 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6280 times.
✗ Branch 5 not taken.
156761 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21073 464 ? true : strcmp(s3," ")!=0))
21074 {
21075 6744 ssc_tile_hei = ssc_tile_hei_buf;
21076
1/2
✓ Branch 0 taken 6744 times.
✗ Branch 1 not taken.
6744 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21077 6744 ssc_tile_hei_buf = -1;
21078 6744 cursor_y += thei + MsgStrings[msgstr].vspace;
21079
2/2
✓ Branch 0 taken 6738 times.
✓ Branch 1 taken 6 times.
6744 if(bottom_margin_clip()) break;
21080 6738 cursor_x=msg_margins[left];
21081 6738 }
21082
21083 156755 cursor_x+=tlength;
21084 156755 ++msgpos;
21085 156755 ++msgptr;
21086
21087
2/2
✓ Branch 0 taken 10215 times.
✓ Branch 1 taken 146540 times.
156755 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21088 {
21089
2/2
✓ Branch 0 taken 87448 times.
✓ Branch 1 taken 59092 times.
146540 if(MsgStrings[msgstr].nextstring)
21090 {
21091
1/2
✓ Branch 0 taken 59092 times.
✗ Branch 1 not taken.
59092 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21092 {
21093 msgstr=MsgStrings[msgstr].nextstring;
21094 msgpos=msgptr=0;
21095 msgfont=setmsgfont();
21096 }
21097 59092 }
21098 146540 }
21099 }
21100 4519 }
21101 }
21102 162613 }
21103 strendcheck:
21104 // Done printing the string
21105
14/14
✓ Branch 0 taken 169192 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 169168 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 168205 times.
✓ Branch 5 taken 963 times.
✓ Branch 6 taken 166973 times.
✓ Branch 7 taken 1232 times.
✓ Branch 8 taken 164336 times.
✓ Branch 9 taken 2637 times.
✓ Branch 10 taken 164330 times.
✓ Branch 11 taken 6 times.
✓ Branch 12 taken 161928 times.
✓ Branch 13 taken 6277 times.
169193 if(do_end_str || !doing_name_insert && !do_run_menu && (msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip() || atend(MsgStrings[msgstr].s.c_str()+msgptr)) && !linkedmsgclk)
21106 {
21107
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6277 times.
6278 if(!do_end_str)
21108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6277 times.
6277 while(parsemsgcode()); // Finish remaining control codes
21109
21110 // Go to next string, or make it disappear by going to string 0.
21111
5/6
✓ Branch 0 taken 4283 times.
✓ Branch 1 taken 1995 times.
✓ Branch 2 taken 3275 times.
✓ Branch 3 taken 1008 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3275 times.
6278 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
21112 {
21113 3003 linkedmsgclk=do_end_str?1:51;
21114 3003 }
21115
21116
2/2
✓ Branch 0 taken 4283 times.
✓ Branch 1 taken 1995 times.
6278 if(MsgStrings[msgstr].nextstring==0)
21117 {
21118
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 3275 times.
4283 if(!get_qr(qr_MSGDISAPPEAR))
21119 3275 {
21120 disappear:
21121 4282 msg_active = false;
21122 4282 Hero.finishedmsg();
21123 4282 }
21124
21125
2/2
✓ Branch 0 taken 5277 times.
✓ Branch 1 taken 13 times.
5290 if(repaircharge)
21126 {
21127 // if (get_qr(qr_REPAIRFIX)) {
21128 // fixed_door=true;
21129 // }
21130 13 game->change_drupy(-tmpscr[currscr<128?0:1].catchall);
21131 13 repaircharge = 0;
21132 13 }
21133
21134
2/2
✓ Branch 0 taken 5288 times.
✓ Branch 1 taken 2 times.
5290 if(adjustmagic)
21135 {
21136
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(get_qr(qr_OLD_HALF_MAGIC))
21137 {
21138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(game->get_magicdrainrate())
21139 2 game->set_magicdrainrate(1);
21140 2 }
21141 else if(game->get_magicdrainrate() > 1)
21142 {
21143 game->set_magicdrainrate(game->get_magicdrainrate()/2);
21144 }
21145 2 adjustmagic = false;
21146 2 sfx(WAV_SCALE);
21147
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21148 2 }
21149
21150
2/2
✓ Branch 0 taken 5288 times.
✓ Branch 1 taken 2 times.
5290 if(learnslash)
21151 {
21152 2 game->set_canslash(1);
21153 2 learnslash = false;
21154 2 sfx(WAV_SCALE);
21155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21156 2 }
21157 5290 }
21158 7285 }
21159 14470936 }
21160
21161 124309 int32_t message_more_y()
21162 {
21163 //Is the flag ticked, do we really want a message more y larger than 160?
21164
5/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 124281 times.
✓ Branch 2 taken 124309 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124281 times.
✓ Branch 5 taken 28 times.
124309 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
21165 124309 msgy+=playing_field_offset;
21166 124309 return msgy;
21167 }
21168
21169 /*** Collision detection & handling ***/
21170
21171 14150398 void clear_script_one_frame_conditions()
21172 {
21173
2/2
✓ Branch 0 taken 38761943 times.
✓ Branch 1 taken 14150398 times.
52912341 for(int32_t j=0; j<guys.Count(); j++)
21174 {
21175 38761943 enemy *e = (enemy*)guys.spr(j);
21176
2/2
✓ Branch 0 taken 658953031 times.
✓ Branch 1 taken 38761943 times.
697714974 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
21177 38761943 }
21178 14150398 }
21179
21180 4851677 void check_enemy_lweapon_collision(weapon *w)
21181 {
21182
8/8
✓ Branch 0 taken 4239600 times.
✓ Branch 1 taken 612077 times.
✓ Branch 2 taken 3250638 times.
✓ Branch 3 taken 988962 times.
✓ Branch 4 taken 3188554 times.
✓ Branch 5 taken 62084 times.
✓ Branch 6 taken 16738 times.
✓ Branch 7 taken 3171816 times.
4851677 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
21183 {
21184
2/2
✓ Branch 0 taken 3156245 times.
✓ Branch 1 taken 11156524 times.
14312769 for(int32_t j=0; j<guys.Count(); j++)
21185 {
21186 11156524 enemy *e = (enemy*)guys.spr(j);
21187
21188 11156524 bool didhit = e->hit(w);
21189
2/2
✓ Branch 0 taken 10936092 times.
✓ Branch 1 taken 220432 times.
11156524 if(didhit) //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
21190 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
21191 {
21192 // !(e->stunclk)
21193 220432 int32_t h = e->takehit(w);
21194
2/2
✓ Branch 0 taken 187002 times.
✓ Branch 1 taken 33430 times.
220432 if (h == -1)
21195 {
21196 33430 int indx = Lwpns.find(w);
21197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33430 times.
33430 if(indx > -1)
21198 33430 e->hitby[HIT_BY_LWEAPON] = indx+1;
21199 33430 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
21200 33430 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
21201
2/2
✓ Branch 0 taken 31260 times.
✓ Branch 1 taken 2170 times.
33430 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
21202 2170 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
21203 33430 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
21204 33430 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
21205
21206 33430 }
21207 //we may need to handle this in special cases. -Z
21208
21209 //if h == stun or ignore
21210
21211 //if e->stun > DEFAULT_STUN -1 || !e->stun
21212 //if the enemy wasn't stunned this round -- what a bitch, as the stun value is set before we check this
21213 ///! how about: if w->dead != bounce !
21214
21215 // NOT FOR PUBLIC RELEASE
21216 /*if(h==3) //Mirror shield
21217 {
21218 if (w->id==ewFireball || w->id==wRefFireball)
21219 {
21220 w->id=wRefFireball;
21221 switch(e->dir)
21222 {
21223 case up: e->angle += (PI - e->angle) * 2.0; break;
21224 case down: e->angle = -e->angle; break;
21225 case left: e->angle += ((-PI/2) - e->angle) * 2.0; break;
21226 case right: e->angle += (( PI/2) - e->angle) * 2.0; break;
21227 // TODO: the following. -L.
21228 case l_up: break;
21229 case r_up: break;
21230 case l_down: break;
21231 case r_down: break;
21232 }
21233 }
21234 else
21235 {
21236 w->id = ((w->id==ewMagic || w->id==wRefMagic || w->id==wMagic) ? wRefMagic : wRefBeam);
21237 w->dir ^= 1;
21238 if(w->dir&2)
21239 w->flip ^= 1;
21240 else
21241 w->flip ^= 2;
21242 }
21243 w->ignoreHero=false;
21244 }
21245 else*/
21246
2/2
✓ Branch 0 taken 176399 times.
✓ Branch 1 taken 44033 times.
220432 if(h)
21247 {
21248
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 44029 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
44033 if(e->switch_hooked && w->family_class == itype_switchhook)
21249 w->onhit(false, e, -1);
21250 44033 else w->onhit(false, e, h);
21251 44033 }
21252
21253
2/2
✓ Branch 0 taken 217758 times.
✓ Branch 1 taken 2674 times.
220432 if(h==2)
21254 {
21255 2674 break;
21256 }
21257 217758 }
21258
21259
2/2
✓ Branch 0 taken 11140953 times.
✓ Branch 1 taken 12897 times.
11153850 if(w->Dead())
21260 {
21261 12897 break;
21262 }
21263 11140953 }
21264
21265 // Item flags added in 2.55:
21266 // BRang/HShot/Arrows item_flag4 is "Pick up anything" (port of qr_BRANGPICKUP)
21267 // BRang/HShot item_flag5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
21268 // Arrows item_flag2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
21269 // -Em
21270
6/6
✓ Branch 0 taken 2717833 times.
✓ Branch 1 taken 453983 times.
✓ Branch 2 taken 2673261 times.
✓ Branch 3 taken 44572 times.
✓ Branch 4 taken 43559 times.
✓ Branch 5 taken 2629702 times.
3171816 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
21271 {
21272 542114 int32_t itype, pitem = w->parentitem;
21273
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 453983 times.
✓ Branch 2 taken 43559 times.
✓ Branch 3 taken 44572 times.
542114 switch(w->id)
21274 {
21275 453983 case wBrang: itype = itype_brang; break;
21276 43559 case wArrow: itype = itype_arrow; break;
21277 case wHookshot:
21278 44572 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
21279 44572 break;
21280 }
21281
2/2
✓ Branch 0 taken 537262 times.
✓ Branch 1 taken 4852 times.
542114 if(pitem < 0) pitem = current_item_id(itype);
21282
5/6
✓ Branch 0 taken 44572 times.
✓ Branch 1 taken 497542 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 44472 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
542114 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & item_flag9))
21283 { //Swap with item
21284 for(int32_t j=0; j<items.Count(); j++)
21285 {
21286 if(items.spr(j)->hit(w))
21287 {
21288 item *theItem = ((item*)items.spr(j));
21289 bool priced = theItem->PriceIndex >-1;
21290 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21291 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21292 || (((itemsbuf[w->parentitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21293 {
21294 if(!Hero.switchhookclk)
21295 {
21296 hooked_combopos = -1;
21297 hooked_layerbits = 0;
21298 switching_object = theItem;
21299 theItem->switch_hooked = true;
21300 w->misc = 2;
21301 w->step = 0;
21302 theItem->clk2=256;
21303 Hero.doSwitchHook(game->get_switchhookstyle());
21304 if(QMisc.miscsfx[sfxSWITCHED])
21305 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x));
21306 }
21307 }
21308 }
21309 }
21310 }
21311
6/6
✓ Branch 0 taken 43559 times.
✓ Branch 1 taken 498555 times.
✓ Branch 2 taken 374095 times.
✓ Branch 3 taken 330536 times.
✓ Branch 4 taken 498555 times.
✓ Branch 5 taken 330536 times.
542114 else if((w->id==wArrow&&itemsbuf[pitem].flags & item_flag2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & item_flag5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
21312 {
21313
2/2
✓ Branch 0 taken 87310 times.
✓ Branch 1 taken 374095 times.
461405 for(int32_t j=0; j<items.Count(); j++)
21314 {
21315
2/2
✓ Branch 0 taken 82412 times.
✓ Branch 1 taken 4898 times.
87310 if(items.spr(j)->hit(w))
21316 {
21317 4898 item *theItem = ((item*)items.spr(j));
21318 4898 bool priced = theItem->PriceIndex >-1;
21319
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 4766 times.
4898 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21320
5/8
✓ Branch 0 taken 4898 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3789 times.
✓ Branch 5 taken 1109 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2065 times.
6963 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21321
4/6
✓ Branch 0 taken 3174 times.
✓ Branch 1 taken 2065 times.
✓ Branch 2 taken 3174 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3174 times.
4898 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey))&& !priced)))
21322 {
21323
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
5854 if(itemsbuf[theItem->id].collect_script)
21324 {
21325 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
21326 }
21327
21328 1724 Hero.checkitems(j);
21329 1724 }
21330 4898 }
21331 87310 }
21332 374095 }
21333
2/2
✓ Branch 0 taken 14738 times.
✓ Branch 1 taken 153281 times.
829091 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
21334 {
21335
2/2
✓ Branch 0 taken 36900 times.
✓ Branch 1 taken 153281 times.
190181 for(int32_t j=0; j<items.Count(); j++)
21336 {
21337
2/2
✓ Branch 0 taken 28212 times.
✓ Branch 1 taken 8688 times.
36900 if(items.spr(j)->hit(w))
21338 {
21339 8688 item *theItem = ((item*)items.spr(j));
21340 8688 bool priced = theItem->PriceIndex >-1;
21341
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8681 times.
8688 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21342
4/6
✓ Branch 0 taken 8688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8454 times.
✓ Branch 5 taken 234 times.
8688 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21343
5/10
✓ Branch 0 taken 7273 times.
✓ Branch 1 taken 1181 times.
✓ Branch 2 taken 1415 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1415 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1415 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8688 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21344 {
21345 7273 int32_t pickup = theItem->pickup;
21346 7273 int32_t id2 = theItem->id;
21347 7273 int32_t pstr = theItem->pstring;
21348 7273 int32_t pstr_flags = theItem->pickup_string_flags;
21349
21350 7273 std::vector<int32_t> &ev = FFCore.eventData;
21351 7273 ev.clear();
21352 7273 ev.push_back(id2*10000);
21353 7273 ev.push_back(pickup*10000);
21354 7273 ev.push_back(pstr*10000);
21355 7273 ev.push_back(pstr_flags*10000);
21356 7273 ev.push_back(0);
21357 7273 ev.push_back(theItem->getUID());
21358 7273 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
21359 7273 ev.push_back(w->getUID());
21360
21361 7273 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
21362 7273 bool nullify = ev[4] != 0;
21363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7273 times.
7273 if(nullify) continue;
21364
2/2
✓ Branch 0 taken 1076 times.
✓ Branch 1 taken 6197 times.
7273 if(w->id == wBrang)
21365 {
21366 6197 w->onhit(false);
21367 6197 }
21368
21369
2/2
✓ Branch 0 taken 6775 times.
✓ Branch 1 taken 498 times.
7273 if(w->dragging==-1)
21370 {
21371 498 w->dead=1;
21372 498 theItem->clk2=256;
21373 498 w->dragging=j;
21374 498 theItem->is_dragged = true;
21375 498 }
21376 7273 }
21377 8688 }
21378 36900 }
21379 153281 }
21380 542114 }
21381 3171816 }
21382 4851677 }
21383 14148242 void check_collisions()
21384 {
21385
2/2
✓ Branch 0 taken 4851642 times.
✓ Branch 1 taken 14148242 times.
18999884 for(uint q = 0; q < Lwpns.Count(); ++q)
21386 4851642 check_enemy_lweapon_collision((weapon*)Lwpns.spr(q));
21387 14148242 }
21388
21389 14150398 void dragging_item()
21390 {
21391
2/2
✓ Branch 0 taken 4966950 times.
✓ Branch 1 taken 14150398 times.
19117348 for(int32_t i=0; i<Lwpns.Count(); i++)
21392 {
21393 4966950 weapon *w = (weapon*)Lwpns.spr(i);
21394
21395
4/4
✓ Branch 0 taken 4504375 times.
✓ Branch 1 taken 462575 times.
✓ Branch 2 taken 4811691 times.
✓ Branch 3 taken 155259 times.
4966950 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & item_flag5)//item_flag5 is a port for qr_Z3BRANG_HSHOT
21396 {
21397
3/4
✓ Branch 0 taken 7247 times.
✓ Branch 1 taken 148012 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7247 times.
155259 if(w->dragging>=0 && w->dragging<items.Count())
21398 {
21399 7247 item* dragItem = (item*)items.spr(w->dragging);
21400 7247 dragItem->x=w->x;
21401 7247 dragItem->y=w->y;
21402
21403 // Drag the Fairy enemy as well as the Fairy item
21404 7247 int32_t id = dragItem->id;
21405
21406
4/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 6828 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 15 times.
7247 if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3)
21407 {
21408 404 movefairynew2(w->x,w->y,*dragItem);
21409 404 }
21410 7247 }
21411 155259 }
21412 4966950 }
21413 14150398 }
21414
21415 55 int32_t more_carried_items()
21416 {
21417 55 int32_t hasmorecarries = 0;
21418
21419
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 55 times.
115 for(int32_t i=0; i<items.Count(); i++)
21420 {
21421
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 55 times.
60 if(((item*)items.spr(i))->pickup & ipENEMY)
21422 {
21423 55 hasmorecarries++;
21424 55 }
21425 60 }
21426
21427 55 return hasmorecarries;
21428 }
21429
21430 // messy code to do the enemy-carrying-the-item thing
21431 14150398 void roaming_item()
21432 {
21433
4/4
✓ Branch 0 taken 28207 times.
✓ Branch 1 taken 14122191 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 28137 times.
14150398 if(!(hasitem&(4|2)) || !loaded_enemies)
21434 14122261 return;
21435
21436 // All enemies already dead upon entering a room?
21437
1/2
✓ Branch 0 taken 28137 times.
✗ Branch 1 not taken.
28137 if(guys.Count()==0)
21438 {
21439 return;
21440 }
21441
21442 // Lost track of the carrier?
21443
5/6
✓ Branch 0 taken 28137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28131 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 28115 times.
✓ Branch 5 taken 16 times.
28137 if(guycarryingitem<0 || guycarryingitem>=guys.Count() ||
21444 28131 !((enemy*)guys.spr(guycarryingitem))->itemguy)
21445 {
21446 22 guycarryingitem=-1;
21447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 for(int32_t j=0; j<guys.Count(); j++)
21448 {
21449
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 22 times.
84 if(((enemy*)guys.spr(j))->itemguy)
21450 {
21451 22 guycarryingitem=j;
21452 22 break;
21453 }
21454 62 }
21455 22 }
21456
21457
2/2
✓ Branch 0 taken 28073 times.
✓ Branch 1 taken 64 times.
28137 if(hasitem&4)
21458 {
21459 64 guycarryingitem = -1;
21460
21461
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 64 times.
477 for(int32_t i=0; i<guys.Count(); i++)
21462 {
21463
2/2
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 64 times.
413 if(((enemy*)guys.spr(i))->itemguy)
21464 {
21465 64 guycarryingitem = i;
21466 64 }
21467 413 }
21468
21469
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(guycarryingitem == -1) //This happens when "default enemies" such as
21470 {
21471 return; //eSHOOTFBALL are alive but enemies from the list
21472 } //are not. Defer to HeroClass::checkspecial().
21473
21474 64 int32_t Item=tmpscr->item;
21475
21476 64 hasitem &= ~4;
21477
21478
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
64 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
21479 {
21480 115 additem(0,0,Item,ipENEMY+ipONETIME+ipBIGRANGE
21481
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 13 times.
64 + (((tmpscr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0)
21482 );
21483 64 hasitem |= 2;
21484 64 }
21485 else
21486 {
21487 return;
21488 }
21489 64 }
21490
21491
2/2
✓ Branch 0 taken 29483 times.
✓ Branch 1 taken 28137 times.
57620 for(int32_t i=0; i<items.Count(); i++)
21492 {
21493
2/2
✓ Branch 0 taken 1346 times.
✓ Branch 1 taken 28137 times.
29483 if(((item*)items.spr(i))->pickup&ipENEMY)
21494 {
21495
2/2
✓ Branch 0 taken 14272 times.
✓ Branch 1 taken 13865 times.
28137 if(get_qr(qr_HIDECARRIEDITEMS))
21496 {
21497 14272 items.spr(i)->x = -128; // Awfully inelegant, innit?
21498 14272 items.spr(i)->y = -128;
21499 14272 }
21500
2/4
✓ Branch 0 taken 13865 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13865 times.
13865 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21501 {
21502
1/2
✓ Branch 0 taken 13865 times.
✗ Branch 1 not taken.
13865 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21503 {
21504 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21505 {
21506 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21507 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21508 }
21509 else
21510 {
21511 if(guys.spr(guycarryingitem)->extend >= 3)
21512 {
21513 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21514 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21515 }
21516 else
21517 {
21518 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21519 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21520 }
21521 }
21522 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21523 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21524 }
21525 else
21526 {
21527 13865 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21528 13865 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21529 13865 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21530 }
21531 13865 }
21532 28137 }
21533 29483 }
21534 14150398 }
21535
21536 bool enemy::IsBigAnim()
21537 {
21538 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
21539 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
21540 || anim == a4FRM8DIRB);
21541 }
21542 2389386 int32_t enemy::getFlashingCSet()
21543 {
21544 //Special cset for the dying sprite
21545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2389386 times.
2389386 if(dying)
21546 {
21547 if (!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading == fade_blue_poof)
21548 return wpnsbuf[spr_death].csets & 15;
21549 else
21550 return (((clk2 + 5) >> 1) & 3) + 6;
21551 }
21552
21553 //Normal cset
21554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2389386 times.
2389386 if (hclk <= 0)
21555 {
21556 //Special cset for the flashing animation
21557 if (flags & guy_flashing)
21558 return (frame & 3) + 6;
21559 return cs;
21560 }
21561
21562 //Hurt animations
21563
2/2
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 2385498 times.
2389386 if(family==eeGANON)
21564 3888 return (((hclk-1)>>1)&3)+6;
21565
4/4
✓ Branch 0 taken 2216661 times.
✓ Branch 1 taken 168837 times.
✓ Branch 2 taken 487138 times.
✓ Branch 3 taken 1729523 times.
2385498 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
21566 1729523 return (((hclk-1)>>1)&3)+6;
21567
21568 655975 return cs;
21569 2389386 }
21570
21571 81517382 bool enemy::is_hitflickerframe(bool olddrawing)
21572 {
21573
6/6
✓ Branch 0 taken 81488878 times.
✓ Branch 1 taken 28504 times.
✓ Branch 2 taken 3939716 times.
✓ Branch 3 taken 77549162 times.
✓ Branch 4 taken 3167025 times.
✓ Branch 5 taken 772691 times.
81517382 if (family == eeGANON || !hclk || !get_qr(qr_ENEMIESFLICKER))
21574 80744691 return false;
21575
21576
3/4
✓ Branch 0 taken 496051 times.
✓ Branch 1 taken 276640 times.
✓ Branch 2 taken 496051 times.
✗ Branch 3 not taken.
772691 if (!olddrawing && !getCanFlicker())
21577 return false;
21578
21579 772691 int32_t fr = game->get_spriteflickerspeed();
21580
1/2
✓ Branch 0 taken 772691 times.
✗ Branch 1 not taken.
772691 if (fr == 0)
21581 return true;
21582 772691 return frame % (fr * 2) < fr;
21583 81517382 }
21584
21585 const char *old_guy_string[OLDMAXGUYS] =
21586 {
21587 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
21588 // 020
21589 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
21590 // 025
21591 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
21592 // 030
21593 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
21594 // 035
21595 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
21596 // 040
21597 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
21598 // 045
21599 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
21600 // 050
21601 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
21602 // 055
21603 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
21604 // 060
21605 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
21606 // 065
21607 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
21608 // 070
21609 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
21610 // 075
21611 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
21612 // 080
21613 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
21614 // 085
21615 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
21616 // 090
21617 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
21618 // 095
21619 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
21620 // 100
21621 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
21622 // 105
21623 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
21624 // 110
21625 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
21626 // 115
21627 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
21628 // 120
21629 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
21630 // 125
21631 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
21632 // 130
21633 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
21634 // 135
21635 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
21636 // 140
21637 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
21638 // 145
21639 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
21640 // 150
21641 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
21642 // 155
21643 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
21644 // 160
21645 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
21646 // 165
21647 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
21648 // 170
21649 "Pols Voice (Magic)", "Pols Voice (Whistle)", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
21650 // 175
21651 "Grappler Bug (HP) ", "Grappler Bug (MP) "
21652 };
21653